home *** CD-ROM | disk | FTP | other *** search
- unit Cciccfrm;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, ExtCtrls, StdCtrls, Buttons, Menus, FileCtrl, CCWSock, CCICCInf,
- CCICCPrf, IniFiles, Gauges , CCUUCode;
-
- type
- { This record holds the information for a number of internet connections }
- PConnectionsRecord = ^TConnectionsRecord;
- TConnectionsRecord = record
- CProfile : String; { Connection profile; used in lists }
- CIPAddress : String; { Dotted character IP Address }
- CUserName : String; { Login name to site; can be anonym }
- CPassword : String; { Password; won't be shown }
- CStartDir : String; { Starting directory; used for FTP }
- end;
- { Array of TCR }
- CRFile = file of TConnectionsRecord; { File type for TCRec }
- { This record is used to hold information about a newsgroup }
- { NOTE : hi and low pointers indicate either dl or trashing without dl }
- { "read" is for an article dl'd but not trashed. }
- PNewsGroupRecord = ^TNewsGroupRecord;
- TNewsGroupRecord = record
- GName : String; { Profile of the newsgroup }
- GRealName : String; { Real Newsrc name of the newsgroup }
- GLowest : Longint; { Number of lowest dl/trashed article }
- GHighest : Longint; { Number of highest dl/trashed article }
- GTotalNew : Longint; { Total New articles available }
- GTotalAvailable : Longint; { After update, shows how many arts on s}
- GLowestAvailable : Longint; { au, shows lowest a# on server }
- GHighestAvailable : Longint; { au, shows highest a# on server }
- GPostable : Boolean; { Can post to newsgroup }
- GSubscribed : Boolean; { Subscribed to newsgroup }
- GTotalArticles : Longint; { Total articles maintained on system }
- GTotalUnReadArticles : Longint; { Total unread articles on system }
- GIDNumber : Integer;
- GFileName : String; { Name of file holding articles records }
- GLTag : Longint; { Tag field to hold pointer to arts TL }
- end;
- NGRFile = file of TNewsGroupRecord; { File type for NGRec }
- { This record is used to hold information about Newsgroup articles }
- PNewsGroupArticleRecord = ^TNewsGroupArticleRecord;
- TNewsGroupArticleRecord = record
- NGAGroupname : String; { Newsgroup name (redundancy safeguard) }
- NGASubject : String; { Subject of article }
- NGANumber : Longint; { Article number }
- NGADownloaded : boolean; { Article attempted/succeeded downloading }
- NGASender : String; { Article's putative sender (CIUPKC158=us) }
- NGARead : Boolean; { Article read flag }
- NGAPosted : Boolean; { Article posted flag }
- NGAArtFileName : String; { Name of system-gen file with article text }
- end;
- NGARFile = file of TNewsGroupArticleRecord;
- { This record is used to hold information about EMail Mailboxes }
- PEMailMailBoxRecord = ^TEMailMailBoxRecord;
- TEMailMailBoxRecord = record
- MBName : String; { Name of the mailbox }
- MBIDNumber : Integer;
- MBMaxMsgNumber : Longint;
- MBTotal : Longint; { Total Mail Messages in Mailbox }
- MBUnReadTotal : Longint; { Total unread Mail Messages in Mailbox }
- MBUnSentTotal : Longint; { Total unsent Mail Messages in Mailbox }
- MBMsgFileName : String; { Name of file holding Messages records }
- MBLTag : Longint; { Tag to pointer to Tlist holding msgrecs }
- end;
- EMMBRFile = file of TEMailMailBoxRecord; { File type for EMMBRec }
- { This record is used to hold information about EMail messages in a Mailbox }
- PEMailMessageRecord = ^TEMailMessageRecord;
- TEMailMessageRecord = record
- MRMailBoxName : String; { Name of mailbox (redundancy safeguard) }
- MRMessageSubject : String; { Subject of the Message }
- MRMessageRecipient : String; { EMail address of primary recipient }
- MRMessageSender : String; { EMail address of sender }
- MRCarbonCopy : String; { EMail CC recips; "|" delimited }
- MRBlindCarbonCopy : String; { EMail BCC recips; "|" delimited }
- MRDateTime : String; { EMail date/time field }
- MRRead : Boolean; { EMail Read flag }
- MRSent : Boolean; { EMail Send flag }
- MRFileName : String; { EMail system generated filename for msg text }
- end;
- EMMRFile = file of TEMailMessageRecord; { File type for EMMRec }
- TCCINetCCForm = class(TForm)
- MainMenu1: TMainMenu;
- Network1: TMenuItem;
- N1: TMenuItem;
- Exit1: TMenuItem;
- Services1: TMenuItem;
- IPAddress1: TMenuItem;
- EMail1: TMenuItem;
- FTP1: TMenuItem;
- UsenetNws1: TMenuItem;
- Panel1: TPanel;
- Panel2: TPanel;
- Panel3: TPanel;
- Panel4: TPanel;
- Panel5: TPanel;
- Panel6: TPanel;
- ListBox1: TListBox;
- Panel7: TPanel;
- SpeedButton1: TSpeedButton;
- SpeedButton2: TSpeedButton;
- ListBox2: TListBox;
- ComboBox1: TComboBox;
- Button1: TButton;
- Memo1: TMemo;
- Files1: TMenuItem;
- Edit1: TMenuItem;
- Encoding1: TMenuItem;
- EMail2: TMenuItem;
- FTP2: TMenuItem;
- News1: TMenuItem;
- Load1: TMenuItem;
- Save1: TMenuItem;
- Cut1: TMenuItem;
- Copy1: TMenuItem;
- CopytoFile1: TMenuItem;
- Paste1: TMenuItem;
- PastefromFile1: TMenuItem;
- UUDecode1: TMenuItem;
- MIMEDecode1: TMenuItem;
- UUEncode1: TMenuItem;
- MIMEEncode1: TMenuItem;
- CheckMail1: TMenuItem;
- ReplyToCurrentMessage1: TMenuItem;
- SendCurrentMessage1: TMenuItem;
- SendQueue1: TMenuItem;
- Mailboxes1: TMenuItem;
- Correspondents1: TMenuItem;
- EmptyTrash1: TMenuItem;
- SpeedButton4: TSpeedButton;
- SpeedButton5: TSpeedButton;
- SpeedButton3: TSpeedButton;
- Panel8: TPanel;
- Label1: TLabel;
- Label2: TLabel;
- ComboBox2: TComboBox;
- Label3: TLabel;
- ComboBox3: TComboBox;
- ConnectToSite1: TMenuItem;
- Disconnect1: TMenuItem;
- UploadMarked1: TMenuItem;
- DownloadMarked1: TMenuItem;
- Directory1: TMenuItem;
- ASCII1: TMenuItem;
- Binary1: TMenuItem;
- ASCII2: TMenuItem;
- Binary2: TMenuItem;
- ViewRemoteasText1: TMenuItem;
- FTPSites1: TMenuItem;
- CheckNewNews1: TMenuItem;
- GetMarked1: TMenuItem;
- CreateNewMessage1: TMenuItem;
- Article1: TMenuItem;
- SubscribedNewsgroups1: TMenuItem;
- Trash1: TMenuItem;
- Preferences1: TMenuItem;
- EMail3: TMenuItem;
- FTP3: TMenuItem;
- News2: TMenuItem;
- Label4: TLabel;
- Label5: TLabel;
- ViewasText1: TMenuItem;
- Change1: TMenuItem;
- Create1: TMenuItem;
- Delete3: TMenuItem;
- ChangeLocal1: TMenuItem;
- OpenDialog1: TOpenDialog;
- SaveDialog1: TSaveDialog;
- Paths1: TMenuItem;
- ProgressInfo1: TMenuItem;
- N2: TMenuItem;
- ViewInEditWindow1: TMenuItem;
- ViewInStatusLine1: TMenuItem;
- SaveToFile1: TMenuItem;
- ViewWinsockInfo1: TMenuItem;
- Description1: TMenuItem;
- SystemStatus1: TMenuItem;
- VendorSpecific1: TMenuItem;
- Gauge1: TGauge;
- NewsServers1: TMenuItem;
- AllReadArticles1: TMenuItem;
- AllMarkedArticles1: TMenuItem;
- AllAvailableArticles1: TMenuItem;
- NewArticle1: TMenuItem;
- FollowupArticle1: TMenuItem;
- Post1: TMenuItem;
- CurrentArticle1: TMenuItem;
- EntireQueue1: TMenuItem;
- ConnectandUpdate1: TMenuItem;
- Disconnect2: TMenuItem;
- Headers1: TMenuItem;
- RetrieveMarked1: TMenuItem;
- RetrieveAll1: TMenuItem;
- DownloadActiveNewsgroups1: TMenuItem;
- PutinQueue1: TMenuItem;
- TrashMarkedMessages1: TMenuItem;
- MailServers1: TMenuItem;
- ExitEMailRequired1: TMenuItem;
- ToCurrentMessage1: TMenuItem;
- ToNewMessage1: TMenuItem;
- ToFile2: TMenuItem;
- AbortNewsgroupDownload1: TMenuItem;
- Catchup1: TMenuItem;
- Marked1: TMenuItem;
- All1: TMenuItem;
- File1: TMenuItem;
- SelectedArticle1: TMenuItem;
- SelectMultipleArticles1: TMenuItem;
- DecodeSelections1: TMenuItem;
- procedure Exit1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure Description1Click(Sender: TObject);
- procedure SystemStatus1Click(Sender: TObject);
- procedure VendorSpecific1Click(Sender: TObject);
- procedure ViewInEditWindow1Click(Sender: TObject);
- procedure ViewInStatusLine1Click(Sender: TObject);
- procedure SaveToFile1Click(Sender: TObject);
- procedure IPAddress1Click(Sender: TObject);
- procedure FTP1Click(Sender: TObject);
- procedure FormResize(Sender: TObject);
- procedure FTPSites1Click(Sender: TObject);
- procedure FTP3Click(Sender: TObject);
- procedure ConnectToSite1Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure ViewasText1Click(Sender: TObject);
- procedure Disconnect1Click(Sender: TObject);
- procedure ToDisplay1Click(Sender: TObject);
- procedure ToFile1Click(Sender: TObject);
- procedure Binary2Click(Sender: TObject);
- procedure Change1Click(Sender: TObject);
- procedure ChangeLocal1Click(Sender: TObject);
- procedure ListBox1DblClick(Sender: TObject);
- procedure ListBox2DblClick(Sender: TObject);
- procedure ASCII1Click(Sender: TObject);
- procedure DeleteRemoteFiles1Click(Sender: TObject);
- procedure Binary1Click(Sender: TObject);
- procedure Delete3Click(Sender: TObject);
- procedure Create1Click(Sender: TObject);
- procedure ListBox1Click(Sender: TObject);
- procedure UsenetNws1Click(Sender: TObject);
- procedure Disconnect2Click(Sender: TObject);
- procedure News2Click(Sender: TObject);
- procedure ConnectandUpdate1Click(Sender: TObject);
- procedure CheckNewNews1Click(Sender: TObject);
- procedure NewsServers1Click(Sender: TObject);
- procedure SubscribedNewsgroups1Click(Sender: TObject);
- procedure RetrieveMarked1Click(Sender: TObject);
- procedure RetrieveAll1Click(Sender: TObject);
- procedure GetMarked1Click(Sender: TObject);
- procedure NewArticle1Click(Sender: TObject);
- procedure FollowupArticle1Click(Sender: TObject);
- procedure PutinQueue1Click(Sender: TObject);
- procedure CurrentArticle1Click(Sender: TObject);
- procedure EntireQueue1Click(Sender: TObject);
- procedure AllReadArticles1Click(Sender: TObject);
- procedure AllMarkedArticles1Click(Sender: TObject);
- procedure AllAvailableArticles1Click(Sender: TObject);
- procedure DownloadActiveNewsgroups1Click(Sender: TObject);
- procedure UUEncode1Click(Sender: TObject);
- procedure Load1Click(Sender: TObject);
- procedure Save1Click(Sender: TObject);
- procedure EMail1Click(Sender: TObject);
- procedure CheckMail1Click(Sender: TObject);
- procedure CreateNewMessage1Click(Sender: TObject);
- procedure ReplyToCurrentMessage1Click(Sender: TObject);
- procedure SendCurrentMessage1Click(Sender: TObject);
- procedure SendQueue1Click(Sender: TObject);
- procedure MailServers1Click(Sender: TObject);
- procedure Mailboxes1Click(Sender: TObject);
- procedure Correspondents1Click(Sender: TObject);
- procedure EMail3Click(Sender: TObject);
- procedure Paths1Click(Sender: TObject);
- procedure ExitEMailRequired1Click(Sender: TObject);
- procedure TrashMarkedMessages1Click(Sender: TObject);
- procedure EmptyTrash1Click(Sender: TObject);
- procedure ComboBox2Change(Sender: TObject);
- procedure ComboBox3Change(Sender: TObject);
- procedure MIMEDecode1Click(Sender: TObject);
- procedure Cut1Click(Sender: TObject);
- procedure Copy1Click(Sender: TObject);
- procedure CopytoFile1Click(Sender: TObject);
- procedure Paste1Click(Sender: TObject);
- procedure PastefromFile1Click(Sender: TObject);
- procedure SpeedButton5Click(Sender: TObject);
- procedure SpeedButton3Click(Sender: TObject);
- procedure SpeedButton1Click(Sender: TObject);
- procedure SpeedButton2Click(Sender: TObject);
- procedure ListBox2Click(Sender: TObject);
- procedure AbortNewsgroupDownload1Click(Sender: TObject);
- procedure Marked1Click(Sender: TObject);
- procedure All1Click(Sender: TObject);
- procedure File1Click(Sender: TObject);
- procedure SelectedArticle1Click(Sender: TObject);
- procedure SelectMultipleArticles1Click(Sender: TObject);
- procedure DecodeSelections1Click(Sender: TObject);
- procedure SpeedButton4Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- procedure EnableFTPMenus;
- procedure DisableFTPMenus;
- procedure EnableNNTPMenus;
- procedure DisableNNTPMenus;
- procedure EnablePOP3SMTPMenus;
- procedure DisablePOP3SMTPMenus;
- procedure UpdateGauge( BytesFinished , TotalToHandle : longint );
- procedure UpdateMailGauge( BytesFinished , TotalToHandle : longint );
- procedure UpdateMIMEGauge( BytesFinished , TotalToHandle : longint );
- procedure UpdateUUGauge( BytesFinished , TotalToHandle : longint );
- function DoFTPConnection( PCRPointer : PConnectionsRecord ) : boolean;
- function DoNNTPConnection( PCRPointer : PConnectionsRecord ) : boolean;
- function DoPOP3Connection( PCRPointer : PConnectionsRecord ) : boolean;
- function DoSMTPConnection( PCRPointer : PConnectionsRecord ) : boolean;
- procedure DoFTPDisconnect;
- procedure DoNNTPDisconnect;
- procedure DoPOP3SMTPDisconnect;
- procedure ReadIniData;
- procedure WriteIniData;
- procedure LoadFTPSiteFile;
- procedure LoadNNTPSiteFile;
- procedure LoadEmailServerFile;
- procedure SaveEMailServerFile;
- procedure LoadEmailMailboxFile( WhichServer : Integer );
- procedure SaveEMailMailboxFile( WhichServer : Integer );
- procedure LoadEmailCorrespondentsFile;
- procedure SaveEMailCorrespondentsFile;
- procedure SetupEMailServerStatus;
- procedure SetupNNTPServersInfoDisplay;
- procedure SaveFTPSiteFile;
- procedure SetupFTPSiteLists;
- procedure SaveNNTPSiteFile;
- procedure SetupNNTPSiteLists;
- procedure SetupNNTPNewsGroupsInfoDisplay;
- procedure SetupNNTPNewsGroupLists;
- procedure SaveNNTPNewsGroupLists;
- procedure SetupNewsGroupListboxes;
- procedure SetupEMailListboxes;
- procedure SetupMailboxLists;
- procedure SetupEMailServersInfoDisplay;
- procedure SetupEMailMailboxInfoDisplay;
- procedure PopulateLB2WithArticleHeaders;
- procedure PopulateLB2WithMessageHeaders;
- procedure SetupEMailCorrespondentsInfoDisplay;
- procedure AddNullTermTextToMemo( TheTextToAdd : String;
- TheMemoToAddTo : TMemo );
- function AddNullTermTextToLabel( TheTextToAdd : String ) : String;
- procedure SetHGCursors;
- procedure SetNormalCursors;
- procedure AddProgressText( WhatText : String );
- procedure ShowProgressText( WhatText : String );
- procedure ShowProgressErrorText( WhatText : String );
- procedure SocketsErrorOccurred( Sender : TObject;
- ErrorCode : Integer;
- TheMessage : String );
- end;
- { Component to hold FTP handling capabilities }
- TFTPComponent = class( TWinControl )
- public
- FTPCommandInProgress ,
- Connection_Established : Boolean;
- Socket1 : TCCSocket;
- Socket2 : TCCSocket;
- constructor Create( AOwner : TComponent ); override;
- destructor Destroy; override;
- function GetTotalBytesToReceive( TheString : String ) : Longint;
- function StripBrackets( TheString : String ) : String;
- function GetShortPathname( TheString : String ) : String;
- function GetWin16FileName( InputName : String ) : String;
- function GetRemoteWorkingDirectory( var RemoteDir : String ) : Boolean;
- function SetRemoteDirectory( TheDir : String ) : Boolean;
- function DeleteRemoteDirectory( TheDir : String ) : Boolean;
- function CreateRemoteDirectory( TheDir : String ) : Boolean;
- function DeleteRemoteFile( TheFileName : String ) : Boolean;
- function EstablishConnection( PCRPointer : PConnectionsRecord ) : Boolean;
- function LoginUser( PCRPointer : PConnectionsRecord ) : Boolean;
- function SendPassword( PCRPointer : PConnectionsRecord ) : Boolean;
- function SetRemoteStartupDirectory( PCRPointer : PConnectionsRecord )
- : Boolean;
- function GetRemoteDirectoryListing( TheListBox : TListBox ) : Boolean;
- function GetRemoteDirectoryListingToMemo : Boolean;
- procedure SendASCIILocalFile( LocalName : String );
- procedure SendBinaryLocalFile( LocalName : String );
- procedure ReceiveASCIIRemoteFile( RemoteName , LocalName : String );
- procedure ReceiveBinaryRemoteFile( RemoteName , LocalName : String );
- function GetLocalDirectoryAndListing( var TheString : String;
- TheListBox : TListBox )
- : Boolean;
- function GetUNIXTextString( var StringIn : String ) : String;
- procedure ReceiveASCIIRemoteFileToMemo( RemoteName : String );
- function GetListeningPort : Integer;
- procedure GetFileNameFromUNIXFileName( var TheName : String );
- function Disconnect : Boolean;
- function DoCStyleFormat( TheText : string;
- const TheArguments : array of const ) : String;
- procedure UpdateGauge( BytesFinished , TotalToHandle : longint );
- function GetQuotedString( TheString : String ) : String;
- procedure AddProgressText( WhatText : String );
- procedure ShowProgressText( WhatText : String );
- procedure ShowProgressErrorText( WhatText : String );
- function GetFTPServerResponse( var ResponseString : String ) : integer;
- procedure FTPSocketsErrorOccurred( Sender : TObject;
- ErrorCode : Integer;
- TheMessage : String );
- function PerformFTPCommand(
- TheCommand : string;
- const TheArguments : array of const ) : Integer;
- end;
- const
- POV_MEMO = 1; { Progress to the Memo }
- POV_STAT = 2; { Progress to the status caption }
- TCPIP_STATUS_PRELIMINARY = 1; { Wait; command being processed }
- TCPIP_STATUS_COMPLETED = 2; { Done; command fully succeded }
- TCPIP_STATUS_CONTINUING = 3; { OK; send more data to finish }
- TCPIP_STATUS_RETRY_COMMAND = 4; { Temporary Error; try cmd again }
- TCPIP_STATUS_FATAL_ERROR = 5; { Fatal Error; don't retry cmd }
-
- var
- CCINetCCForm : TCCINetCCForm;
- GlobalErrorCode : Integer; { Used to pass around error info }
- GlobalAbortedFlag : Boolean; { Used to signal timeout error }
- ProgressList : TStringList; { Used to hold progress text info }
- ProgressFileName : String; { Used to hold progress file name }
- ProgressOutputVector : Integer; { Used to direct progress output }
- TheFTPSiteList : TList; { Used to store the FTP site recs }
- TheWorkingFTPSL : TList; { Used to store working copy of l }
- TheNewsServerList : TList; { Used to hold list of NNTP servs }
- TheWorkingNSSL : TList; { Used for working copy of above }
- TheEMailServerList : TList; { Used for list of POP3/SMTP serv }
- TheWorkingEMSL : TList; { Used for working copy of above }
- TheNewsRCList : TList; { Used for list of available ngs }
- TheWorkingNRCSL : TList; { Used for working copy of above }
- TheNGArticlesList : TList; { Used for current articles list }
- { (will hot swap from pointer of }
- { Tlist of Tlists in base rec.) }
- TheEMailMailboxList : TList; { Used for list of available mbs }
- TheWorkingMBSL : TList; { Used for working copy of above }
- TheCorrespondentsList: TList; { Used for list of correspondents }
- TheWorkingCPSL : TList; { Used for working copy of above }
- TheMBMessagesList : TList; { Used for current msgs; hotswaps }
- TheEMailServerFile : CRFile; { File of Email servers records }
- TheEMailCorrespondentsFile : CRFile;
- TheNewsServerFile : CRFile; { File of NNTP servers records }
- TheNewsRCFile : NGRFile; { File of Newsgroups records }
- TheNewsArticleFile : NGARFile; { Current ng articles records file}
- TheEMailMailboxFile : EMMBRFile; { File of Mailboxes records }
- TheEMailMessagesFile : EMMRFile; { Current mb messages records file}
- TheFTPSiteFile : CRFile; { Used to load the FTP site file }
- TheICCIniFile : TIniFile; { Used to retrieve the INI File }
- MailPath : String; { Used for path to Mail Files }
- NewsPath : String; { Used for path to News Files }
- FTPPath : String; { Used for path to FTP Files }
- CurrentPassWordString : String; { Used to hold login id for anons }
- CurrentEMPassWordString : String; { Used to hold login id for anons }
- PassWordControlVector : Integer; { Used to hold display of pw vect }
- CurrentRealPWString : String; { Used to hold a real password }
- EMPassWordControlVector : Integer; { Used to hold display of pw vect }
- CurrentEMRealPWString : String; { Used to hold a real password }
- TheFTPComponent : TFTPComponent; { FTP Object }
- TheLine ,
- HolderLine ,
- GlobalTextBuffer : String;
- TheAnonRedialVector ,
- DefaultDownloadVector : Integer;
- NewsReadArticlePurgingVector : Integer;
- NewsPostQueueingVector : Integer;
- NewsReadArticleDisplayVector : Integer;
- NewsUUMIMEVector : Integer;
- NewsInitialUpdateVector : Integer;
- LeftoverText : String;
- LeftoversOnTable : Boolean;
- FileNameToXFer : String;
- WhichServer : Integer; { Holds current NNTP server }
- WhichGroup : Integer; { Holds current NNTP newsgroup }
- TheUUObject : TUUCodingObject;
- EMRemoteDeletionVector : Integer;
- EMChokeVector : Integer;
- EMDefaultDownloadVector : Integer;
- EMQueueVector : Integer;
- NewsgroupListLoaded ,
- EmailLoaded ,
- NewMessageInProgress : Boolean;
- TheUUDecodeList : TStringList;
-
- implementation
-
- uses CCICCPOP, CCICNNTP;
-
- var
- TheNNTPComponent : TNNTPComponent;{ NNTP News Object }
-
- {$R *.DFM}
-
-
- { This procedure actually attempts to connect to the internet at an POP3SMTP site }
- function TCCINetCCForm.DoPOP3Connection( PCRPointer : PConnectionsRecord ) : boolean;
- begin
- { Create the component }
- Result := false;
- { Do busy cursors }
- SetHGCursors;
- if not ThePOP3SMTPComponent.EstablishPOP3Connection( PCRPointer ) then
- begin
- { Do saved cursors }
- ThePOP3SMTPComponent.POP3CommandInProgress := false;
- ThePOP3SMTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end;
- if not ThePOP3SMTPComponent.LoginUser( PCRPointer ) then
- begin
- { Do saved cursors }
- ThePOP3SMTPComponent.POP3CommandInProgress := false;
- ThePOP3SMTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end;
- if not ThePOP3SMTPComponent.SendPassword( PCRPointer ) then
- begin
- { Do saved cursors }
- ThePOP3SMTPComponent.POP3CommandInProgress := false;
- ThePOP3SMTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end;
- SetNormalCursors;
- Result := true;
- EnablePOP3SMTPMenus;
- ThePOP3SMTPComponent.POP3CommandInProgress := false;
- Panel1.Caption := ' Status : Connected to ' + PCRPointer^.CIPAddress;
- end;
-
- { This procedure actually attempts to connect to the internet at an POP3SMTP site }
- function TCCINetCCForm.DoSMTPConnection( PCRPointer : PConnectionsRecord ) : boolean;
- begin
- { Create the component }
- Result := false;
- { Do busy cursors }
- SetHGCursors;
- if not ThePOP3SMTPComponent.EstablishSMTPConnection( PCRPointer ) then
- begin
- { Do saved cursors }
- ThePOP3SMTPComponent.SMTPCommandInProgress := false;
- ThePOP3SMTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end;
- if not ThePOP3SMTPComponent.SendHelo( PCRPointer ) then
- begin
- { Do saved cursors }
- ThePOP3SMTPComponent.SMTPCommandInProgress := false;
- ThePOP3SMTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end;
- SetNormalCursors;
- Result := true;
- ThePOP3SMTPComponent.SMTPCommandInProgress := false;
- Panel1.Caption := ' Status : Connected to ' + PCRPointer^.CIPAddress;
- end;
-
- { This procedure actually attempts to disconnect to the internet at an ftp site}
- procedure TCCINetCCForm.DoPOP3SMTPDisconnect;
- begin
- { Kill the socket }
- ThePOP3SMTPComponent.Socket1.CCSockClose;
- ThePOP3SMTPComponent.Connection_Established := false;
- end;
-
- { Procedure to load the POP3SMTP Site list }
- procedure TCCINetCCForm.LoadEmailServerFile;
- var ThePSSRecord : PConnectionsRecord; { Generic TCR Pointer }
- PSSLName : String; { POP3SMTP Site List filename }
- Counter_1 : Integer; { Loop counter }
- begin
- { Create the sites list list }
- TheEMailServerList := TList.Create;
- { Set up the FTP sites list file name }
- PSSLName := MailPath + '\PSSERVER.TCR';
- { If the FTP Site List exists load it in }
- if FileExists( PSSLName ) then
- begin
- { set up the file and open it }
- AssignFile( TheEMailServerFile , PSSLName );
- Reset( TheEMailServerFile );
- { read in the records }
- for Counter_1 := 0 to FileSize( TheEMailServerFile ) - 1 do
- begin
- { Create the TCRecord }
- New( ThePSSRecord );
- { Read in the data record }
- Seek( TheEMailServerFile , Counter_1 );
- Read( TheEMailServerFile , ThePSSRecord^ );
- { Add the record to the list }
- TheEMailServerList.Add( ThePSSRecord );
- end;
- { close the file }
- CloseFile( TheEMailServerFile );
- end
- else
- { Otherwise create a default one with the a generic mail site (?) }
- begin
- { create new record }
- New( ThePSSRecord );
- { fill in its info }
- with ThePSSRecord^ do
- begin
- CProfile := 'My Mail Server';
- CIPAddress := 'mail.myprovider.com';
- CUserName := 'myname';
- CPassword := 'mypassword';
- CStartDir := 'myname@myprovider.com';
- end;
- { add it to the list }
- { do it three more times }
- TheEMailServerList.Add( ThePSSRecord );
- { create the file and write out the data, then close it }
- AssignFile( TheEMailServerFile , PSSLName );
- Rewrite( TheEMailServerFile );
- ThePSSRecord :=
- PConnectionsRecord( TheEMailServerList.Items[ 0 ] );
- Seek( TheEMailServerFile , 0 );
- Write( TheEMailServerFile , ThePSSRecord^ );
- CloseFile( TheEMailServerFile );
- end;
- TheWorkingEMSL := TList.Create;
- For Counter_1 := 0 to TheEMailServerList.Count - 1 do
- begin
- New( ThePSSRecord );
- ThePSSRecord^ := PConnectionsRecord( TheEMailServerList.Items[ Counter_1 ] )^;
- TheWorkingEMSL.Add( ThePSSRecord );
- end;
- end;
-
- procedure TCCINetCCForm.SaveEMailServerFile;
- var ThePSSRecord : PConnectionsRecord; { The TC Record pointer }
- PSSLName : String; { POP3SMTP Site List filename }
- Counter_1 : Integer; { Loop counter }
- begin
- { Set up the file name }
- PSSLName := MailPath + '\PSSERVER.TCR';
- { Assign the file }
- AssignFile( TheEMailServerFile , PSSLName );
- { Rewrite it }
- Rewrite( TheEMailServerFile );
- { run the list through the procedure }
- for Counter_1 := 0 to TheEMailServerList.Count - 1 do
- begin
- { get the record from the list }
- ThePSSRecord :=
- PConnectionsRecord( TheEMailServerList.Items[ Counter_1 ] );
- { Do the seek/write }
- Seek( TheEMailServerFile , Counter_1 );
- Write( TheEMailServerFile , ThePSSRecord^ );
- { free the record }
- Dispose( ThePSSRecord );
- end;
- { Close the file }
- CloseFile( TheEMailServerFile );
- { Free the list pointers }
- TheEMailServerList.Free;
- for Counter_1 := 0 to TheWorkingEMSL.Count - 1 do
- begin
- ThePSSRecord := PConnectionsRecord( TheWorkingEMSL.Items[ Counter_1 ] );
- Dispose( ThePSSRecord );
- end;
- TheWorkingEMSL.Free;
- end;
-
- { Procedure to load the POP3SMTP Site list }
- procedure TCCINetCCForm.LoadEmailMailboxFile( WhichServer : Integer );
- var TheMBRecord : PEMailMailboxRecord; { Generic TCR Pointer }
- PSMBName : String; { Mailbox filename }
- Counter_1 ,
- Counter_2 : Integer; { Loop counter }
- TheMessagesList : TList;
- TheEMMRecord : PEMailMessageRecord;
- begin
- { Create the sites list list }
- TheEMailMailboxList := TList.Create;
- { Set up the FTP sites list file name }
- PSMBName := MailPath + '\MAILBX' + IntToStr( WhichServer ) + '.MBX';
- { If the FTP Site List exists load it in }
- if FileExists( PSMBName ) then
- begin
- { set up the file and open it }
- AssignFile( TheEMailMailboxFile , PSMBName );
- Reset( TheEMailMailboxFile );
- { read in the records }
- for Counter_1 := 0 to FileSize( TheEMailMailboxFile ) - 1 do
- begin
- { Create the TCRecord }
- New( TheMBRecord );
- { Read in the data record }
- Seek( TheEMailMailboxFile , Counter_1 );
- Read( TheEMailMailboxFile , TheMBRecord^ );
- { Add the record to the list }
- TheEMailMailboxList.Add( TheMBRecord );
- end;
- { close the file }
- CloseFile( TheEMailMailboxFile );
- end
- else
- { Otherwise create a default one with the In and Out mailboxes (?) }
- begin
- { create new record }
- New( TheMBRecord );
- { fill in its info }
- with TheMBRecord^ do
- begin
- MBName := 'In Box';
- MBIDNumber := 1;
- MBMaxMsgNumber := 0;
- MBTotal := 0;
- MBUnReadTotal := 0;
- MBUnSentTotal := 0;
- MBMsgFileName := 'MB1.MBX';
- MBLTag := 0;
- end;
- { add it to the list }
- TheEMailMailboxList.Add( TheMBRecord );
- { create new record }
- New( TheMBRecord );
- { fill in its info }
- with TheMBRecord^ do
- begin
- MBName := 'Out Box';
- MBIDNumber := 2;
- MBMaxMsgNumber := 0;
- MBTotal := 0;
- MBUnReadTotal := 0;
- MBUnSentTotal := 0;
- MBMsgFileName := 'MB2.MBX';
- MBLTag := 0;
- end;
- { add it to the list }
- TheEMailMailboxList.Add( TheMBRecord );
- { create the file and write out the data, then close it }
- AssignFile( TheEMailMailboxFile , PSMBName );
- Rewrite( TheEMailMailboxFile );
- TheMBRecord :=
- PEMailMailboxRecord( TheEMailMailboxList.Items[ 0 ] );
- Seek( TheEMailMailboxFile , 0 );
- Write( TheEMailMailboxFile , TheMBRecord^ );
- TheMBRecord :=
- PEMailMailboxRecord( TheEMailMailboxList.Items[ 1 ] );
- Seek( TheEMailMailboxFile , 1 );
- Write( TheEMailMailboxFile , TheMBRecord^ );
- CloseFile( TheEMailMailboxFile );
- end;
- { Load in Message Records and create storage lists }
- for Counter_1 := 0 to TheEMailMailboxList.Count - 1 do
- begin
- PSMBName := PEMailMailboxRecord(
- TheEMailMailboxList.Items[ Counter_1 ] )^.MBMsgFileName;
- if FileExists( MailPath + '\' + PSMBName ) then
- begin
- TheMessagesList := TList.Create;
- AssignFile( TheEMailMessagesFile , MailPath + '\' + PSMBName );
- Reset( TheEMailMessagesFile );
- for Counter_2 := 0 to FileSize( TheEMailMessagesFile ) - 1 do
- begin
- New( TheEMMRecord );
- Seek( TheEMailMessagesFile , Counter_2 );
- Read( TheEMailMessagesFile , TheEMMRecord^ );
- TheMessagesList.Add( TheEMMRecord );
- end;
- CloseFile( TheEMailMessagesFile );
- PEMailMailboxRecord( TheEMailMailboxList.Items[ Counter_1 ] )^.MBLTag :=
- Longint( TheMessagesList );
- end
- else
- begin
- TheMessagesList := TList.Create;
- PEMailMailboxRecord( TheEMailMailboxList.Items[ Counter_1 ] )^.MBLTag :=
- Longint( TheMessagesList );
- end;
- end;
- TheWorkingMBSL := TList.Create;
- For Counter_1 := 0 to TheEMailMailboxList.Count - 1 do
- begin
- New( TheMBRecord );
- TheMBRecord^ := PEMailMailboxRecord( TheEMailMailboxList.Items[ Counter_1 ] )^;
- TheWorkingMBSL.Add( TheMBRecord );
- end;
- end;
-
- procedure TCCINetCCForm.SaveEMailMailboxFile( WhichServer : Integer );
- var TheMBRecord : PEMailMailboxRecord; { Generic TCR Pointer }
- PSMBName : String; { Mailbox filename }
- Counter_2 ,
- Counter_1 : Integer; { Loop counter }
- TheList : TList;
- TheEMMRecord : PEMailMessageRecord;
- begin
- { Load in Message Records and create storage lists }
- for Counter_1 := 0 to TheEMailMailboxList.Count - 1 do
- begin
- PSMBName := PEMailMailboxRecord(
- TheEMailMailboxList.Items[ Counter_1 ] )^.MBMsgFileName;
- TheList := TList( PEMailMailboxRecord(
- TheEMailMailboxList.Items[ Counter_1 ] )^.MBLTag );
- AssignFile( TheEMailMessagesFile , Mailpath + '\' + PSMBName );
- Rewrite( TheEMailMessagesFile );
- for Counter_2 := 0 to TheList.Count - 1 do
- begin
- TheEMMRecord := PEMailMessageRecord( TheList.Items[ Counter_2 ] );
- Seek( TheEMailMessagesFile , Counter_2 );
- Write( TheEMailMessagesFile , TheEMMRecord^ );
- Dispose( TheEMMRecord );
- end;
- CloseFile( TheEMailMessagesFile );
- TheList.Free;
- end;
- { Set up the file name }
- PSMBName := MailPath + '\MAILBX' + IntToStr( WhichServer ) + '.MBX';
- { Assign the file }
- AssignFile( TheEMailMailboxFile , PSMBName );
- { Rewrite it }
- Rewrite( TheEMailMailboxFile );
- { run the list through the procedure }
- for Counter_1 := 0 to TheEMailMailboxList.Count - 1 do
- begin
- { get the record from the list }
- TheMBRecord :=
- PEMailMailboxRecord( TheEMailMailboxList.Items[ Counter_1 ] );
- { Do the seek/write }
- Seek( TheEMailMailboxFile , Counter_1 );
- Write( TheEMailMailboxFile , TheMBRecord^ );
- { free the record }
- Dispose( TheMBRecord );
- end;
- { Close the file }
- CloseFile( TheEMailMailboxFile );
- { Free the list pointers }
- TheEMailMailboxList.Free;
- for Counter_1 := 0 to TheWorkingMBSL.Count - 1 do
- begin
- TheMBRecord := PEMailMailboxRecord( TheWorkingMBSL.Items[ Counter_1 ] );
- Dispose( TheMBRecord );
- end;
- TheWorkingMBSL.Free;
- end;
-
- { Procedure to load the POP3SMTP Site list }
- procedure TCCINetCCForm.LoadEmailCorrespondentsFile;
- var ThePSSRecord : PConnectionsRecord; { Generic TCR Pointer }
- PSSLName : String; { POP3SMTP Site List filename }
- Counter_1 : Integer; { Loop counter }
- begin
- { Create the sites list list }
- TheCorrespondentsList := TList.Create;
- { Set up the FTP sites list file name }
- PSSLName := MailPath + '\PSCORRSP.TCR';
- { If the FTP Site List exists load it in }
- if FileExists( PSSLName ) then
- begin
- { set up the file and open it }
- AssignFile( TheEMailCorrespondentsFile , PSSLName );
- Reset( TheEMailCorrespondentsFile );
- { read in the records }
- for Counter_1 := 0 to FileSize( TheEMailCorrespondentsFile ) - 1 do
- begin
- { Create the TCRecord }
- New( ThePSSRecord );
- { Read in the data record }
- Seek( TheEMailCorrespondentsFile , Counter_1 );
- Read( TheEMailCorrespondentsFile , ThePSSRecord^ );
- { Add the record to the list }
- TheCorrespondentsList.Add( ThePSSRecord );
- end;
- { close the file }
- CloseFile( TheEMailCorrespondentsFile );
- end
- else
- { Otherwise create a default one with the author }
- begin
- { create new record }
- New( ThePSSRecord );
- { fill in its info }
- with ThePSSRecord^ do
- begin
- CProfile := 'Nathan Wallace at TDE';
- CIPAddress := 'kilgalen@tde.com';
- CUserName := '';
- CPassword := '';
- CStartDir := '';
- end;
- { add it to the list }
- { do it three more times }
- TheCorrespondentsList.Add( ThePSSRecord );
- { create the file and write out the data, then close it }
- AssignFile( TheEMailCorrespondentsFile , PSSLName );
- Rewrite( TheEMailCorrespondentsFile );
- ThePSSRecord :=
- PConnectionsRecord( TheCorrespondentsList.Items[ 0 ] );
- Seek( TheEMailCorrespondentsFile , 0 );
- Write( TheEMailCorrespondentsFile , ThePSSRecord^ );
- CloseFile( TheEMailCorrespondentsFile );
- end;
- TheWorkingCPSL := TList.Create;
- For Counter_1 := 0 to TheCorrespondentsList.Count - 1 do
- begin
- New( ThePSSRecord );
- ThePSSRecord^ := PConnectionsRecord( TheCorrespondentsList.Items[ Counter_1 ] )^;
- TheWorkingCPSL.Add( ThePSSRecord );
- end;
- CCInetCCForm.ComboBox2.Clear;
- CCInetCCForm.ComboBox3.Clear;
- { Add the new info }
- for Counter_1 := 0 to TheWorkingCPSL.Count - 1 do
- begin
- CCINetCCForm.ComboBox2.Items.Add( PConnectionsRecord(
- TheCorrespondentsList.Items[ Counter_1 ] )^.CProfile );
- CCINetCCForm.ComboBox3.Items.Add( PConnectionsRecord(
- TheCorrespondentsList.Items[ Counter_1 ] )^.CProfile );
- end;
- CCINetCCForm.ComboBox2.ItemIndex := 0;
- CCINetCCForm.ComboBox3.ItemIndex := 0;
- end;
-
- procedure TCCINetCCForm.SaveEMailCorrespondentsFile;
- var ThePSSRecord : PConnectionsRecord; { The TC Record pointer }
- PSSLName : String; { POP3SMTP Site List filename }
- Counter_1 : Integer; { Loop counter }
- begin
- { Set up the file name }
- PSSLName := MailPath + '\PSCORRSP.TCR';
- { Assign the file }
- AssignFile( TheEMailCorrespondentsFile , PSSLName );
- { Rewrite it }
- Rewrite( TheEMailCorrespondentsFile );
- { run the list through the procedure }
- for Counter_1 := 0 to TheCorrespondentsList.Count - 1 do
- begin
- { get the record from the list }
- ThePSSRecord :=
- PConnectionsRecord( TheCorrespondentsList.Items[ Counter_1 ] );
- { Do the seek/write }
- Seek( TheEMailCorrespondentsFile , Counter_1 );
- Write( TheEMailCorrespondentsFile , ThePSSRecord^ );
- { free the record }
- Dispose( ThePSSRecord );
- end;
- { Close the file }
- CloseFile( TheEMailCorrespondentsFile );
- { Free the list pointers }
- TheCorrespondentsList.Free;
- for Counter_1 := 0 to TheWorkingCPSL.Count - 1 do
- begin
- ThePSSRecord := PConnectionsRecord( TheWorkingCPSL.Items[ Counter_1 ] );
- Dispose( ThePSSRecord );
- end;
- TheWorkingCPSL.Free;
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupEMailServerStatus;
- begin
- { Set up display for main form }
- CCINetCCForm.Tag := 6; { Email Tag }
- CCINetCCForm.Caption := 'CC Internet Command Center -- EMail Mode';
- CCINetCCForm.ViewWinsockInfo1.Enabled := false;
- CCINetCCForm.EMail2.Enabled := true;
- CCINetCCForm.EMail1.Enabled := false;
- CCINetCCForm.UsenetNws1.Enabled := false;
- CCINetCCForm.FTP1.Enabled := false;
- CCINetCCForm.Label1.Caption := 'Mail Server:';
- CCINetCCForm.Button1.Caption := 'New Mail';
- CCINetCCForm.Label4.Caption := 'Mailboxes';
- CCINetCCForm.Label5.Caption := 'Messages';
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupMailboxLists;
- var TheEMMRecord : PEMailMessageRecord; { }
- Counter_1 ,
- Counter_2 : Integer; { }
- EMMFileName : String; { }
- WorkingList : TList;
- begin
- { Abort if no server to select }
- if ComboBox1.ItemIndex = -1 then exit;
- { Get number of server in list }
- WhichServer := ComboBox1.ItemIndex;
- { Load in mailbox data }
- LoadEmailMailboxFile( WhichServer );
- { Load in Mailbox Records and create storage lists }
- for Counter_1 := 0 to TheEMailMailboxList.Count - 1 do
- begin
- EMMFileName := PEMailMailboxRecord(
- TheEMailMailboxList.Items[ Counter_1 ] )^.MBMsgFileName;
- if FileExists( MailPath + '\' + EMMFileName ) then
- begin
- WorkingList := TList.Create;
- AssignFile( TheEMailMessagesFile , EMMFileName );
- Reset( TheEMailMessagesFile );
- for Counter_2 := 0 to FileSize( TheEMailMessagesFile ) - 1 do
- begin
- New( TheEMMRecord );
- Seek( TheEMailMessagesFile , Counter_2 );
- Read( TheEMailMessagesFile , TheEMMRecord^ );
- WorkingList.Add( TheEMMRecord );
- end;
- CloseFile( TheEMailMessagesFile );
- PEMailMailboxRecord( TheEMailMailboxList.Items[ Counter_1 ] )^.MBLTag :=
- Longint( WorkingList );
- end
- else
- begin
- WorkingList := TList.Create;
- PEMailMailboxRecord( TheEMailMailboxList.Items[ Counter_1 ] )^.MBLTag :=
- Longint( WorkingList );
- end;
- end;
- end;
-
- { This procedure populates LB2 with article subjects for any }
- { available articles for a given newsgroup. }
- procedure TCCINetCCForm.PopulateLB2WithMessageHeaders;
- var Counter_1 : Integer;
- TheEMMRecord : PEMailMessageRecord;
- TempString : String;
- begin
- { Clear target list box }
- ListBox2.Clear;
- for Counter_1 := 0 to TheMBMessagesList.Count - 1 do
- begin
- TheEMMRecord :=
- PEMailMessageRecord( TheMBMessagesList.Items[ Counter_1 ] );
- TempString := ' [' + IntToStr( Counter_1 + 1 ) + '] ' +
- TheEMMRecord^.MRMessageSubject;
- if TheEMMRecord^.MRRead then TempString[ 2 ] := 'R';
- if TheEMMRecord^.MRSent then TempString[ 2 ] := 'S';
- if TheEMMRecord^.MRMessageSender = 'DELETE ME' then TempString[ 3 ] := 'T';
- ListBox2.Items.Add( TempString );
- end;
- end;
-
- { This procedure swaps in the list of subscribed newsgroups to LB1 }
- { and calls another procedure to populate LB2 with any available }
- { articles for the newsgroup. }
- procedure TCCINetCCForm.SetupEMailListboxes;
- var Counter_1 : Integer;
- TempString : String;
- TheMBRecord : PEMailMailboxRecord;
- begin
- ListBox1.Clear;
- ListBox1.Tag := 6;
- ListBox2.Tag := 6;
- Label4.Caption := 'Mailboxes';
- Label5.Caption := 'Messages';
- if TheEMailMailboxList.Count = 0 then
- begin
- ListBox2.Clear;
- exit;
- end;
- for Counter_1 := 0 to TheEMailMailboxList.Count - 1 do
- begin
- TheMBRecord := PEMailMailboxRecord( TheEMailMailboxList.Items[ Counter_1 ] );
- TempString := TheMBRecord^.MBName;
- if TheMBRecord^.MBUnSentTotal > 0 then TempString := TempString + ' {' +
- IntToStr( TheMBRecord^.MBUnSentTotal ) + ' Queued}' else
- if TheMBRecord^.MBUnReadTotal > 0 then TempString := TempString +
- ' {' + IntToStr( TheMBRecord^.MBUnReadTotal ) + ' New}';
- TempString := TempString + '{' + IntToStr( TheMBRecord^.MBTotal ) + ' Stored}';
- ListBox1.Items.Add( TempString );
- end;
- TheMBRecord := PEMailMailboxRecord( TheEMailMailboxList.Items[ 0 ] );
- TheMBMessagesList := TList( TheMBRecord^.MBLTag );
- PopulateLB2WithMessageHeaders;
- Label1.Caption := 'MailBox:';
- Button1.Caption := 'New Mail';
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupEMailServersInfoDisplay;
- var Counter_1 : Integer; { Loop counter }
- begin
- { Set tag for POP3SMTP stuff }
- CCICInfoDlg.Tag := 6; { EMail Tag -- servers }
- { set up caption of main label }
- CCICInfoDlg.Label2.Caption := 'EMail Server Sites';
- { hide outline panel }
- CCICInfoDlg.Panel6.Top := 200;
- CCICInfoDlg.panel6.Height := 144;
- CCICInfoDlg.Panel6.Visible := false;
- CCICInfoDlg.Panel5.Visible := true;
- CCICInfoDlg.Panel8.Visible := true;
- CCICInfoDlg.Panel9.Visible := true;
- { clear the list box }
- CCICInfoDlg.ListBox1.Visible := false;
- CCICInfoDlg.ListBox2.Clear;
- CCINetCCForm.ComboBox1.Clear;
- { add profile strings to the list box }
- for Counter_1 := 0 to TheEMailServerList.Count - 1 do
- begin
- CCICInfoDlg.ListBox2.Items.Add( PConnectionsRecord(
- TheEMailServerList.Items[ Counter_1 ] )^.CProfile );
- CCINetCCForm.ComboBox1.Items.Add( PConnectionsRecord(
- TheEMailServerList.Items[ Counter_1 ] )^.CProfile );
- end;
- { Set up caption of special button }
- CCICInfoDlg.Button1.Visible := false;
- { Start with top record }
- CCICInfoDlg.ListBox2.ItemIndex := 0;
- CCINetCCForm.ComboBox1.ItemIndex := 0;
- { put in data from top record and reset captions }
- with PConnectionsRecord( TheEMailServerList.Items[ 0 ] )^ do
- begin
- with CCICInfoDlg do
- begin
- Edit1.Text := CProfile;
- Panel2.Caption := ' Name:';
- Edit2.Text := CIPAddress;
- Panel3.Caption := ' IP Address:';
- Edit3.Text := CUserName;
- Panel5.Caption := ' User Name:';
- CurrentEMRealPWString := CPassword;
- case EMPasswordControlVector of
- 1 : Edit4.Text := CPassword;
- 2 : Edit4.Text := '**********';
- end;
- Panel8.Caption := ' Password:';
- Edit5.Text := CStartDir;
- Panel9.Caption := ' EMail Address:';
- end;
- end;
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupEMailMailboxInfoDisplay;
- var Counter_1 : Integer;
- TheWorkingList : TList;
- begin
- { Set tag for POP3SMTP stuff }
- CCICInfoDlg.Tag := 7; { EMail Tag -- mailboxes }
- { set up caption of main label }
- CCICInfoDlg.Label2.Caption := 'Mailboxes';
- { hide outline panel }
- CCICInfoDlg.Panel6.Visible := true;
- CCICInfoDlg.Panel6.Top := 40;
- CCICInfoDlg.Panel6.Height := 304;
- CCICInfoDlg.Label1.Caption := 'Saved Messages';
- CCICInfoDlg.Panel3.Visible := false;
- CCICInfoDlg.Panel5.Visible := false;
- CCICInfoDlg.Panel8.Visible := false;
- CCICInfoDlg.Panel9.Visible := false;
- { clear the list box }
- CCICInfoDlg.ListBox1.Visible := true;
- CCICInfoDlg.ListBox1.MultiSelect := true;
- CCICInfoDlg.ListBox1.ExtendedSelect := true;
- CCICInfoDlg.ListBox2.Clear;
- CCICInfoDlg.ListBox1.Clear;
- { add profile strings to the list box }
- for Counter_1 := 0 to TheEMailMailboxList.Count - 1 do
- begin
- CCICInfoDlg.ListBox2.Items.Add( PEMailMailboxRecord(
- TheEMailMailboxList.Items[ Counter_1 ] )^.MBName );
- end;
- { Set up caption of special button }
- CCICInfoDlg.Button1.Visible := true;
- CCICInfoDlg.Button1.Caption := 'XFer on Click';
- { Start with top record }
- CCICInfoDlg.ListBox2.ItemIndex := 0;
- { put in data from top record and reset captions }
- with PEMailMailboxRecord( TheEMailMailboxList.Items[ 0 ] )^ do
- begin
- with CCICInfoDlg do
- begin
- Edit1.Text := MBName;
- Panel2.Caption := 'MB Name:';
- TheWorkingList := TList( MBLTag );
- if TheWorkingList.Count > 0 then
- begin
- ListBox1.Clear;
- for Counter_1 := 0 to TheWorkingList.Count - 1 do
- begin
- ListBox1.Items.Add( PEMailMessageRecord(
- TheWorkingList.Items[ Counter_1 ] )^.MRMessageSubject );
- end;
- Listbox1.ItemIndex := 0;
- end;
- end;
- end;
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupEMailCorrespondentsInfoDisplay;
- var Counter_1 : Integer; { Loop counter }
- begin
- { Set tag for POP3SMTP stuff }
- CCICInfoDlg.Tag := 8; { EMail Tag -- correspondents }
- { set up caption of main label }
- CCICInfoDlg.Label2.Caption := 'Correspondents';
- { hide outline panel }
- CCICInfoDlg.Panel3.Visible := true;
- CCICInfoDlg.Panel6.Visible := false;
- CCICInfoDlg.Panel5.Visible := false;
- CCICInfoDlg.Panel8.Visible := false;
- CCICInfoDlg.Panel9.Visible := false;
- CCICInfoDlg.ListBox1.Visible := false;
- { clear the list box }
- CCICInfoDlg.ListBox2.Clear;
- { add profile strings to the list box }
- for Counter_1 := 0 to TheCorrespondentsList.Count - 1 do
- begin
- CCICInfoDlg.ListBox2.Items.Add( PConnectionsRecord(
- TheCorrespondentsList.Items[ Counter_1 ] )^.CProfile );
- end;
- { Set up caption of special button }
- CCICInfoDlg.Button1.Visible := false;
- { Start with top record }
- CCICInfoDlg.ListBox2.ItemIndex := 0;
- { put in data from top record and reset captions }
- with PConnectionsRecord( TheCorrespondentsList.Items[ 0 ] )^ do
- begin
- with CCICInfoDlg do
- begin
- Edit1.Text := CProfile;
- Panel2.Caption := ' Name:';
- Edit2.Text := CIPAddress;
- Panel3.Caption := 'EMail Address:';
- end;
- end;
- end;
-
- procedure TCCINetCCForm.EnablePOP3SMTPMenus;
- begin
- Button1.Caption := 'New Mail';
- CheckMail1.Enabled := true;
- CreateNewMessage1.Enabled := true;
- ReplyToCurrentMessage1.Enabled := true;
- SendCurrentMessage1.Enabled := true;
- SendQueue1.Enabled := true;
- MailServers1.Enabled := true;
- MailBoxes1.Enabled := true;
- Correspondents1.Enabled := true;
- TrashMarkedMessages1.Enabled := true;
- EmptyTrash1.Enabled := true;
- end;
-
- procedure TCCINetCCForm.DisablePOP3SMTPMenus;
- begin
- CheckMail1.Enabled := False;
- CreateNewMessage1.Enabled := False;
- ReplyToCurrentMessage1.Enabled := False;
- SendCurrentMessage1.Enabled := False;
- SendQueue1.Enabled := False;
- MailServers1.Enabled := False;
- MailBoxes1.Enabled := False;
- Correspondents1.Enabled := False;
- TrashMarkedMessages1.Enabled := False;
- EmptyTrash1.Enabled := False;
- EMail1.Enabled := true;
- FTP1.Enabled := true;
- UseNetNws1.Enabled := true;
- IPAddress1.Enabled := true;
- EMail2.Enabled := false;
- end;
-
- { This is the FTP component constructor; it creates 2 sockets }
- constructor TFTPComponent.Create( AOwner : TComponent );
- begin
- { do inherited create }
- inherited Create( AOwner );
- { Create sockets, put in their parents, and error procs }
- Socket1 := TCCSocket.Create( Self );
- Socket1.Parent := Self;
- Socket1.OnErrorOccurred := FTPSocketsErrorOccurred;
- Socket2 := TCCSocket.Create( Self );
- Socket2.Parent := Self;
- Socket2.OnErrorOccurred := FTPSocketsErrorOccurred;
- { Set up booleans }
- Connection_Established := false;
- FTPCommandInProgress := false;
- end;
-
- { This is the FTP component destructor; it frees 2 sockets }
- destructor TFTPComponent.Destroy;
- begin
- { Free the sockets }
- Socket1.Free;
- Socket2.Free;
- { and call inherited }
- inherited Destroy;
- end;
-
- function TFTPComponent.GetShortPathname( TheString : String ) : String;
- var HoldingString : String;
- begin
- HoldingString := Copy( TheString , 1 , 3 );
- HoldingString := HoldingString + '..\' + ExtractFileName( TheString );
- Result := HoldingString;
- end;
-
- function TFTPComponent.StripBrackets( TheString : String ) : String;
- var HoldingString : String;
- HoldingPosition : Integer;
- begin
- HoldingPosition := Pos( '[' , TheString );
- if HoldingPosition = 0 then
- begin
- Result := TheString;
- exit;
- end
- else
- begin
- HoldingString := Copy( TheString , HoldingPosition + 1 , 255 );
- HoldingPosition := Pos( ']' , HoldingString );
- if HoldingPosition = 0 then
- begin
- Result := HoldingString;
- exit;
- end
- else
- begin
- HoldingString := Copy( HoldingString , 1 , HoldingPosition - 1 );
- Result := HoldingString;
- exit;
- end;
- end;
- end;
-
- { This function takes a UNIX filespec and turns it into a Win16 filename }
- function TFTPComponent.GetWin16FileName( InputName : String ) : String;
- var WorkingString ,
- HoldingString : String; { Holding string }
- begin
- WorkingString := ExtractFileExt( InputName );
- if WorkingString = '' then
- begin
- if Length( InputName ) > 8 then
- WorkingString := Copy( InputName , 1 , 8 ) else
- WorkingString := InputName;
- end
- else
- begin
- if Length( WorkingString ) > 4 then
- WorkingString := Copy( WorkingString , 1 , 4 );
- HoldingString :=
- Copy( InputName , 1 , Pos( WorkingString , InputName ) - 1 );
- if Length( HoldingString ) > 8 then
- HoldingString := Copy( HoldingString , 1 , 8 );
- if HoldingString = '' then
- begin
- { Dot file }
- HoldingString := Copy( InputName , 2 , 255 ) + '.TXT';
- WorkingString := HoldingString;
- end
- else WorkingString := HoldingString + WorkingString;
- end;
- Result := WorkingString;
- end;
-
- { This sends a local file in binary mode to the remote server }
- procedure TFTPComponent.SendBinaryLocalFile( LocalName : String );
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- Through : Boolean;
- FileNamePChar : array[ 0 .. 255 ] of char;
- OutputFileHandle : Integer;
- TotalBytesSent ,
- BytesRead ,
- FileToSendSize : Longint;
- CopyBuffer : array[ 0 .. 255 ] of char absolute TheReturnString;
- begin
- LocalName := ExpandFileName( LocalName );
- StrPCopy( FileNamePChar , LocalName );
- OutputFileHandle := _lopen( FileNamePChar , 0 );
- if OutputFileHandle = -1 then
- begin
- MessageDlg( 'Cannot Open local file ' + LocalName ,
- mtError , [mbOK] , 0 );
- exit;
- end;
- FileToSendSize := _llseek( OutputFileHandle , 0 , 2 );
- _llseek( OutputFileHandle , 0 , 0 );
- TheReturnString :=
- DoCStyleFormat( 'TYPE I' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'TYPE I',
- [ nil ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP File Send Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { leave }
- exit;
- end
- else
- begin
- { Set up socket 2 for listening }
- Socket2.AsynchMode := False;
- Socket2.NonAsynchTimeoutValue := 60;
- { do a listen and send command to server that this is receipt socket }
- if GetListeningPort = TCPIP_STATUS_FATAL_ERROR then
- begin
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket1.NonAsynchTimeoutValue := 0; {infinite timeout}
- TheReturnString :=
- DoCStyleFormat( 'STOR %s' ,
- [ ExtractFileName( LocalName ) ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- TheResult := PerformFTPCommand( 'STOR %s' , [ ExtractFileName( LocalName ) ] );
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- Socket1.NonAsynchTimeoutValue := 30;
- if (( TheResult = TCPIP_STATUS_RETRY_COMMAND ) or
- ( TheResult = TCPIP_STATUS_FATAL_ERROR )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not create remote file!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket2.CCSockAccept;
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not establish send socket!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- exit;
- end;
- Through := false;
- TotalBytesSent := 0;
- BytesRead := _lread( OutputFileHandle , @CopyBuffer[ 1 ] , 255 );
- repeat
- if BytesRead = 0 then Through := true;
- if BytesRead > 0 then
- begin
- CopyBuffer[ 0 ] := Chr( BytesRead );
- Socket2.StringData := TheReturnString;
- TotalBytesSent := TotalBytesSent + BytesRead;
- UpdateGauge( TotalBytesSent , FileToSendSize );
- BytesRead := _lread( OutputFileHandle , @CopyBuffer[ 1 ] , 255 );
- if BytesRead = -1 then
- begin
- MessageDlg( 'File Read Error on ' + LocalName , mtError , [mbOK] , 0 );
- GlobalAbortedFlag := True;
- end;
- end;
- if GlobalAbortedFlag then
- begin
- Socket1.OutOfBand := 'ABOR'+#13#10;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- exit;
- end;
- until Through;
- FTPCommandInProgress := false;
- { cancel listening on second socket and close it }
- Socket2.CCSockCancelListen;
- Socket2.CCSockClose;
- TheReturnString := 'Transfer Succeeded' + #13#10;
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- FTPCommandInProgress := false;
- PerformFTPCommand( 'TYPE A',
- [ nil ] );
- Through := false;
- repeat
- GetFTPServerResponse( TheReturnString );
- if Pos( 'TYPE' , Uppercase( TheReturnString )) > 0 then
- Through := true;
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or Through );
- end;
- _lclose( OutputFileHandle );
- FTPCommandInProgress := false;
- end;
-
- { This sends a local file in ascii mode to remote server }
- procedure TFTPComponent.SendASCIILocalFile( LocalName : String );
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- Through : Boolean;
- FileNamePChar : array[ 0 .. 255 ] of char;
- OutputFileHandle : Integer;
- TotalBytesSent ,
- BytesRead ,
- FileToSendSize : Longint;
- CopyBuffer : array[ 0 .. 255 ] of char absolute TheReturnString;
- begin
- LocalName := ExpandFileName( LocalName );
- StrPCopy( FileNamePChar , LocalName );
- OutputFileHandle := _lopen( FileNamePChar , 0 );
- if OutputFileHandle = -1 then
- begin
- MessageDlg( 'Cannot Open local file ' + LocalName ,
- mtError , [mbOK] , 0 );
- exit;
- end;
- FileToSendSize := _llseek( OutputFileHandle , 0 , 2 );
- _llseek( OutputFileHandle , 0 , 0 );
- TheReturnString :=
- DoCStyleFormat( 'TYPE A' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'TYPE A',
- [ nil ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP File Send Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { leave }
- exit;
- end
- else
- begin
- { Set up socket 2 for listening }
- Socket2.AsynchMode := False;
- Socket2.NonAsynchTimeoutValue := 60;
- { do a listen and send command to server that this is receipt socket }
- if GetListeningPort = TCPIP_STATUS_FATAL_ERROR then
- begin
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket1.NonAsynchTimeoutValue := 0; {infinite timeout}
- TheReturnString :=
- DoCStyleFormat( 'STOR %s' ,
- [ ExtractFileName( LocalName ) ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- TheResult := PerformFTPCommand( 'STOR %s' , [ ExtractFileName( LocalName )]);
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- Socket1.NonAsynchTimeoutValue := 30;
- if (( TheResult = TCPIP_STATUS_RETRY_COMMAND ) or
- ( TheResult = TCPIP_STATUS_FATAL_ERROR )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not create remote file!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket2.CCSockAccept;
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not establish send socket!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- exit;
- end;
- Through := false;
- TotalBytesSent := 0;
- BytesRead := _lread( OutputFileHandle , @CopyBuffer[ 1 ] , 255 );
- repeat
- if BytesRead = 0 then Through := true;
- if BytesRead > 0 then
- begin
- CopyBuffer[ 0 ] := Chr( BytesRead );
- Socket2.StringData := TheReturnString;
- TotalBytesSent := TotalBytesSent + BytesRead;
- UpdateGauge( TotalBytesSent , FileToSendSize );
- BytesRead := _lread( OutputFileHandle , @CopyBuffer[ 1 ] , 255 );
- if BytesRead = -1 then
- begin
- MessageDlg( 'File Read Error on ' + LocalName , mtError , [mbOK] , 0 );
- GlobalAbortedFlag := True;
- end;
- end;
- if GlobalAbortedFlag then
- begin
- Socket1.OutOfBand := 'ABOR'+#13#10;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- exit;
- end;
- until Through;
- { cancel listening on second socket and close it }
- Socket2.CCSockCancelListen;
- Socket2.CCSockClose;
- TheReturnString := 'Transfer Succeeded' + #13#10;
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- FTPCommandInProgress := false;
- PerformFTPCommand( 'TYPE A', [ nil ] );
- Through := false;
- repeat
- GetFTPServerResponse( TheReturnString );
- if Pos( 'TYPE' , Uppercase( TheReturnString )) > 0 then
- Through := true;
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or Through );
- end;
- _lclose( OutputFileHandle );
- FTPCommandInProgress := false;
- end;
-
- { This function strips out the FTP response for bytes to send }
- function TFTPComponent.GetTotalBytesToReceive( TheString : String ) : Longint;
- var
- LeftPosition ,
- RightPosition : integer;
- TempString : string;
- begin
- LeftPosition := Pos( '(' , TheString );
- TempString := Copy( TheString ,
- LeftPosition + 1 , 255 );
- RightPosition := Pos( ' ' , TempString );
- if (( LeftPosition = 0 ) or ( RightPosition = 0 )) then
- begin
- Result := 0;
- exit;
- end;
- if RightPosition <> 0 then
- TempString := Copy( TempString , 1 , RightPosition - 1 );
- try
- Result := StrToInt( TempString );
- except
- on EConvertError do Result := 0;
- end;
- end;
-
- procedure TFTPComponent.UpdateGauge( BytesFinished , TotalToHandle : longint );
- begin
- CCInetCCForm.UpdateGauge( BytesFinished , TotalToHandle );
- end;
-
- { This sends FTP progress text to the Inet form }
- procedure TFTPComponent.AddProgressText( WhatText : String );
- begin
- CCInetCCForm.AddProgressText( WhatText );
- end;
-
- { This sends FTP progress text to the Inet form }
- procedure TFTPComponent.ShowProgressText( WhatText : String );
- begin
- CCInetCCForm.ShowProgressText( WhatText );
- end;
-
- { This procedure receives a binary remote file }
- procedure TFTPComponent.ReceiveASCIIRemoteFileToMemo( RemoteName : String );
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- Through : Boolean;
- TotalBytesSent ,
- FileToGetSize : Longint;
- begin
- TheReturnString :=
- DoCStyleFormat( 'TYPE A' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- FTPCommandInProgress := false;
- TheResult := PerformFTPCommand( 'TYPE A',
- [ nil ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP File Receive Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { leave }
- exit;
- end
- else
- begin
- { Set up socket 2 for listening }
- Socket2.AsynchMode := False;
- Socket2.NonAsynchTimeoutValue := 60;
- { do a listen and send command to server that this is receipt socket }
- if GetListeningPort = TCPIP_STATUS_FATAL_ERROR then
- begin
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket1.NonAsynchTimeoutValue := 0; {infinite timeout}
- TheReturnString :=
- DoCStyleFormat( 'RETR %s' ,
- [ RemoteName ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- TheResult := PerformFTPCommand( 'RETR %s' , [RemoteName] );
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- FileToGetSize := GetTotalBytesToReceive( TheReturnString );
- Socket1.NonAsynchTimeoutValue := 30;
- if (( TheResult = TCPIP_STATUS_RETRY_COMMAND ) or
- ( TheResult = TCPIP_STATUS_FATAL_ERROR )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not obtain remote file!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket2.CCSockAccept;
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not establish receive socket!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- exit;
- end;
- Through := false;
- TotalBytesSent := 0;
- repeat
- TheReturnString := Socket2.StringData;
- if Length( TheReturnString ) = 0 then Through := true;
- if Length( TheReturnString ) > 0 then
- begin
- TotalBytesSent := TotalBytesSent + Length( TheReturnString );
- UpdateGauge( TotalBytesSent , FileToGetSize );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- end;
- if GlobalAbortedFlag then
- begin
- Socket1.OutOfBand := 'ABOR'+#13#10;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- exit;
- end;
- until Through;
- { cancel listening on second socket and close it }
- Socket2.CCSockCancelListen;
- Socket2.CCSockClose;
- FTPCommandInProgress := false;
- PerformFTPCommand( 'TYPE A', [ nil ] );
- Through := false;
- repeat
- GetFTPServerResponse( TheReturnString );
- if Pos( 'TYPE' , Uppercase( TheReturnString )) > 0 then
- Through := true;
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or Through );
- end;
- FTPCommandInProgress := false;
- end;
-
- { This procedure receives a binary remote file }
- procedure TFTPComponent.ReceiveASCIIRemoteFile( RemoteName , LocalName : String );
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- Through : Boolean;
- FileNamePChar : array[ 0 .. 255 ] of char;
- OutputFileHandle : Integer;
- TotalBytesSent ,
- FileToGetSize : Longint;
- CopyBuffer : array[ 0 .. 255 ] of char;
- begin
- LocalName := ExpandFileName( LocalName );
- StrPCopy( FileNamePChar , LocalName );
- OutputFileHandle := _lcreat( FileNamePChar , 0 );
- if OutputFileHandle = -1 then
- begin
- MessageDlg( 'Cannot Create local file ' + LocalName ,
- mtError , [mbOK] , 0 );
- exit;
- end;
- TheReturnString :=
- DoCStyleFormat( 'TYPE A' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'TYPE A',
- [ nil ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP File Receive Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { leave }
- exit;
- end
- else
- begin
- { Set up socket 2 for listening }
- Socket2.AsynchMode := False;
- Socket2.NonAsynchTimeoutValue := 60;
- { do a listen and send command to server that this is receipt socket }
- if GetListeningPort = TCPIP_STATUS_FATAL_ERROR then
- begin
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket1.NonAsynchTimeoutValue := 0; {infinite timeout}
- TheReturnString :=
- DoCStyleFormat( 'RETR %s' ,
- [ RemoteName ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- TheResult := PerformFTPCommand( 'RETR %s' , [RemoteName] );
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- FileToGetSize := GetTotalBytesToReceive( TheReturnString );
- Socket1.NonAsynchTimeoutValue := 30;
- if (( TheResult = TCPIP_STATUS_RETRY_COMMAND ) or
- ( TheResult = TCPIP_STATUS_FATAL_ERROR )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not obtain remote file!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket2.CCSockAccept;
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not establish receive socket!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- exit;
- end;
- Through := false;
- TotalBytesSent := 0;
- repeat
- TheReturnString := Socket2.StringData;
- if Length( TheReturnString ) = 0 then Through := true;
- if Length( TheReturnString ) > 0 then
- begin
- StrPCopy( CopyBuffer , TheReturnString );
- TotalBytesSent := TotalBytesSent + Length( TheReturnString );
- UpdateGauge( TotalBytesSent , FileToGetSize );
- if _lwrite( OutputFileHandle , CopyBuffer , Length( TheReturnString ))
- = -1 then
- begin
- MessageDlg( 'File Write Error on ' + LocalName , mtError , [mbOK] , 0 );
- GlobalAbortedFlag := True;
- end;
- end;
- if GlobalAbortedFlag then
- begin
- Socket1.OutOfBand := 'ABOR'+#13#10;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- exit;
- end;
- until Through;
- { cancel listening on second socket and close it }
- Socket2.CCSockCancelListen;
- Socket2.CCSockClose;
- FTPCommandInProgress := false;
- PerformFTPCommand( 'TYPE A', [ nil ] );
- Through := false;
- repeat
- GetFTPServerResponse( TheReturnString );
- if Pos( 'TYPE' , Uppercase( TheReturnString )) > 0 then
- Through := true;
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or Through );
- end;
- _lclose( OutputFileHandle );
- FTPCommandInProgress := false;
- end;
-
- { This procedure receives a binary remote file }
- procedure TFTPComponent.ReceiveBinaryRemoteFile( RemoteName , LocalName : String );
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- Through : Boolean;
- FileNamePChar : array[ 0 .. 255 ] of char;
- OutputFileHandle : Integer;
- TotalBytesSent ,
- FileToGetSize : Longint;
- CopyBuffer : array[ 0 .. 255 ] of char;
- begin
- LocalName := ExpandFileName( LocalName );
- StrPCopy( FileNamePChar , LocalName );
- OutputFileHandle := _lcreat( FileNamePChar , 0 );
- if OutputFileHandle = -1 then
- begin
- MessageDlg( 'Cannot Create local file ' + LocalName ,
- mtError , [mbOK] , 0 );
- exit;
- end;
- TheReturnString :=
- DoCStyleFormat( 'TYPE I' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'TYPE I',
- [ nil ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP File Receive Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { leave }
- exit;
- end
- else
- begin
- { Set up socket 2 for listening }
- Socket2.AsynchMode := False;
- Socket2.NonAsynchTimeoutValue := 60;
- { do a listen and send command to server that this is receipt socket }
- if GetListeningPort = TCPIP_STATUS_FATAL_ERROR then
- begin
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket1.NonAsynchTimeoutValue := 0; {infinite timeout}
- TheReturnString :=
- DoCStyleFormat( 'RETR %s' ,
- [ RemoteName ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- TheResult := PerformFTPCommand( 'RETR %s' , [RemoteName] );
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- FileToGetSize := GetTotalBytesToReceive( TheReturnString );
- Socket1.NonAsynchTimeoutValue := 30;
- if (( TheResult = TCPIP_STATUS_RETRY_COMMAND ) or
- ( TheResult = TCPIP_STATUS_FATAL_ERROR )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not obtain remote file!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket2.CCSockAccept;
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not establish receive socket!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- exit;
- end;
- Through := false;
- TotalBytesSent := 0;
- repeat
- TheReturnString := Socket2.StringData;
- if Length( TheReturnString ) = 0 then Through := true;
- if Length( TheReturnString ) > 0 then
- begin
- StrPCopy( CopyBuffer , TheReturnString );
- TotalBytesSent := TotalBytesSent + Length( TheReturnString );
- UpdateGauge( TotalBytesSent , FileToGetSize );
- if _lwrite( OutputFileHandle , CopyBuffer , Length( TheReturnString ))
- = -1 then
- begin
- MessageDlg( 'File Write Error on ' + LocalName , mtError , [mbOK] , 0 );
- GlobalAbortedFlag := True;
- end;
- end;
- if GlobalAbortedFlag then
- begin
- Socket1.OutOfBand := 'ABOR'+#13#10;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- exit;
- end;
- until Through;
- { cancel listening on second socket and close it }
- Socket2.CCSockCancelListen;
- Socket2.CCSockClose;
- FTPCommandInProgress := false;
- PerformFTPCommand( 'TYPE A', [ nil ] );
- Through := false;
- repeat
- GetFTPServerResponse( TheReturnString );
- if Pos( 'TYPE' , Uppercase( TheReturnString )) > 0 then
- Through := true;
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or Through );
- end;
- _lclose( OutputFileHandle );
- FTPCommandInProgress := false;
- end;
-
- { This sends FTP progress text to the Inet form }
- procedure TFTPComponent.ShowProgressErrorText( WhatText : String );
- begin
- CCInetCCForm.ShowProgressErrorText( WhatText );
- end;
-
- { This is a core function! It performs an FTP command and if no timeout }
- { return a preliminary ok. }
- function TFTPComponent.PerformFTPCommand(
- TheCommand : string;
- const TheArguments : array of const ) : Integer;
- var TheBuffer : string; { Text buffer }
- begin
- { If command in progress send back -1 error }
- if FTPCommandInProgress then
- begin
- Result := -1;
- exit;
- end;
- { Set status variable }
- FTPCommandInProgress := True;
- { Set global error code }
- GlobalErrorCode := 0;
- { Format output string }
- TheBuffer := Format( TheCommand , TheArguments );
- { Preset failure code }
- Result := TCPIP_STATUS_FATAL_ERROR;
- { If invalid socket or no connection abort }
- if ( Socket1.TheSocket = INVALID_SOCKET ) or not Connection_Established then
- exit;
- { Send the buffer plus EOL chars }
- Socket1.StringData := TheBuffer + #13#10;
- { if abort due to timeout or other error exit }
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then exit;
- { Otherwise return preliminary code }
- Result := TCPIP_STATUS_PRELIMINARY;
- end;
-
- { This function gets up to 255 chars of data plus a return code from FTP serv }
- function TFTPComponent.GetFTPServerResponse(
- var ResponseString : String ) : integer;
- var
- { Buffer string for response line }
- TheBuffer : string;
- { Pointer to the response string }
- BufferPointer : array[0..255] of char absolute TheBuffer;
- { Character to check for response code }
- ResponseChar : char;
- { Pointers into returned string }
- TheIndex ,
- TheLength : integer;
- { Control variable }
- LeftoversInPan ,
- Finished : Boolean;
- begin
- { Preset fatal error }
- Result := TCPIP_STATUS_FATAL_ERROR;
- { Start loop control }
- LeftoversInPan := false;
- Finished := false;
- repeat
- { Do a peek }
- TheBuffer := Socket1.PeekData;
- { If timeout or other error exit }
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then exit;
- { Find end of line character }
- TheIndex := Pos( #10 , TheBuffer );
- if TheIndex = 0 then
- begin
- TheIndex := Pos( #13 , TheBuffer );
- if TheIndex = 0 then
- begin
- TheIndex := Pos( #0 , TheBuffer );
- if TheIndex = 0 then
- begin
- TheIndex := Length( TheBuffer );
- LeftoversInPan := True;
- LeftoverText := LeftoverText + TheBuffer;
- LeftoversOnTable := false;
- end;
- end;
- end;
- { If an end of line then process the line }
- if TheIndex > 0 then
- begin
- { Get length of string }
- TheLength := TheIndex;
- { Receive actual data }
- Socket1.CCSockReceive( Socket1.TheSocket ,
- @BufferPointer[ 1 ] ,
- TheLength );
- { Abort if timeout or error }
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then exit;
- { Put in the length byte }
- BufferPointer[ 0 ] := Chr( TheLength );
- if LeftOversOnTable then
- begin
- LeftOversOnTable := false;
- ResponseString := LeftoverText + TheBuffer;
- TheBuffer := ResponseString;
- LeftoverText := '';
- end;
- if LeftoversInPan then
- begin
- LeftoversInPan := false;
- LeftoversOnTable := true;
- end;
- { If not a continuation line }
- if TheBuffer[ 4 ] <> '-' then
- begin
- { Get first number character }
- ResponseChar := TheBuffer[ 1 ];
- { Get the value of the number from 1 to 5 }
- if (( ResponseChar >= '1' ) and ( ResponseChar <= '5' )) then
- begin
- Finished := true;
- Result := Ord( ResponseChar ) - 48;
- end;
- end
- else
- begin
- { otherwise return preliminary result }
- Finished := true;
- Result := TCPIP_STATUS_PRELIMINARY;
- end;
- end
- else
- begin
- end;
- until ( Finished and ( not LeftoversOnTable ));
- { Return buffer as response string }
- ResponseString := TheBuffer;
- end;
-
- { Boilerplate error routine }
- procedure TFTPComponent.FTPSocketsErrorOccurred( Sender : TObject;
- ErrorCode : Integer;
- TheMessage : String );
- begin
- CCInetCCForm.SocketsErrorOccurred( Sender,ErrorCode,TheMessage );
- end;
-
- { This is the FTP components initial connection routine }
- function TFTPComponent.EstablishConnection(
- PCRPointer : PConnectionsRecord ) : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- { Set default FTP Port value }
- Socket1.PortName := '21';
- { Get the ip address from the record }
- Socket1.IPAddressName := PCRPointer^.CIPAddress;
- { Set blocking mode }
- Socket1.AsynchMode := False;
- { Clear condition variables }
- GlobalErrorCode := 0;
- GlobalAbortedFlag := false;
- { Actually attempt to connect }
- Socket1.CCSockConnect;
- { Check if connected }
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 ) or
- ( Socket1.TheSocket = INVALID_SOCKET )) then
- begin { Didn't connect; signal error and abort }
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host %s Connection Failed!' ,
- [ PCRPointer^.CIPAddress ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else
- begin
- Connection_Established := true;
- { Signal successful connection }
- TheReturnString := DoCStyleFormat(
- 'Connected on Local port: %s with IP: %s',
- [ Socket1.GetSocketPort( Socket1.TheSocket ),
- Socket1.GetSocketIPAddress( Socket1.TheSocket )]);
- { Put result in progress and status line }
- CCINetCCForm.AddProgressText( TheReturnString );
- CCINetCCForm.ShowProgressText( TheReturnString );
- TheReturnString := DoCStyleFormat(
- 'Connected to Remote port: %s with IP: %s',
- [ Socket1.GetSocketPeerPort( Socket1.TheSocket ),
- Socket1.GetSocketPeerIPAddress( Socket1.TheSocket )]);
- { Put result in progress and status line }
- CCINetCCForm.AddProgressText( TheReturnString );
- CCINetCCForm.ShowProgressText( TheReturnString );
- TheReturnString := DoCStyleFormat( 'Successfully connected to %s',
- [ Socket1.IPAddressName ]);
- { Put result in progress and status line }
- CCINetCCForm.AddProgressText( TheReturnString );
- CCINetCCForm.ShowProgressText( TheReturnString );
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host %s Connection Failed!' ,
- [ PCRPointer^.CIPAddress ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
- end;
-
- { This is the FTP components USER login routine }
- function TFTPComponent.LoginUser(
- PCRPointer : PConnectionsRecord ) : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- TheReturnString :=
- DoCStyleFormat( 'USER %s' ,
- [ PCRPointer^.CUserName ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Begin login sequence with user name }
- TheResult := PerformFTPCommand( 'USER %s',
- [ PCRPointer^.CUserName ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- FTPCommandInProgress := false;
- Result := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_CONTINUING )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host %s Connection Failed!' ,
- [ PCRPointer^.CIPAddress ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
-
- function TFTPComponent.DeleteRemoteDirectory( TheDir : String ) : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- TheReturnString := DoCStyleFormat( 'RMD %s' ,
- [ TheDir ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'RMD %s',
- [ TheDir ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := false;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'Delete Directory %s Failed!' ,
- [ TheDir ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
-
- function TFTPComponent.CreateRemoteDirectory( TheDir : String ) : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- TheReturnString := DoCStyleFormat( 'MKD %s' ,
- [ TheDir ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'MKD %s',
- [ TheDir ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := false;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'Create Directory %s Failed!' ,
- [ TheDir ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
-
-
- function TFTPComponent.DeleteRemoteFile( TheFileName : String ) : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- TheReturnString := DoCStyleFormat( 'DELE %s' ,
- [ TheFileName ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'DELE %s',
- [ TheFileName ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := false;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'Delete File %s Failed!' ,
- [ TheFileName ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
-
- { This is the FTP components PASSWORD routine }
- function TFTPComponent.SendPassword(
- PCRPointer : PConnectionsRecord ) : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- TheReturnString := 'PASS XXXXXX' + #13#10;
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'PASS %s',
- [ PCRPointer^.CPassword ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := false;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host %s Connection Failed!' ,
- [ PCRPointer^.CIPAddress ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
-
- { This is the FTP components CWD routine }
- function TFTPComponent.SetRemoteStartupDirectory(
- PCRPointer : PConnectionsRecord ) : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- Result := true;
- if PCRPointer^.CStartDir <> '' then
- begin
- TheReturnString :=
- DoCStyleFormat( 'CWD %s' ,
- [ PCRPointer^.CStartDir ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'CWD %s',
- [ PCRPointer^.CStartDir ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := false;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'CWD to %s Failed!' ,
- [ PCRPointer^.CStartDir ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
- end;
-
- { This is the FTP components CWD routine }
- function TFTPComponent.SetRemoteDirectory( TheDir : String ) : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- Result := true;
- if TheDir <> '' then
- begin
- TheReturnString :=
- DoCStyleFormat( 'CWD %s' ,
- [ TheDir ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'CWD %s',
- [ TheDir ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := false;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'CWD to %s Failed!' ,
- [ TheDir ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
- end;
-
- { This is the FTP components QUIT routine }
- function TFTPComponent.Disconnect : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- TheReturnString :=
- DoCStyleFormat( 'QUIT' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Begin login sequence with user name }
- PerformFTPCommand( 'QUIT', [ nil ] );
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host Connection Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else Result := true; { Signal no problem }
- end;
-
- { This is the FTP components PWD routine }
- function TFTPComponent.GetRemoteWorkingDirectory( var RemoteDir : String )
- : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- begin
- TheReturnString :=
- DoCStyleFormat( 'PWD' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'PWD',
- [ nil ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := false;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host Connection Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := False;
- { leave }
- exit;
- end
- else
- begin
- Result := true; { Signal no problem }
- RemoteDir := TheReturnString; { Send back last string on faith }
- end;
- end;
-
- { This function sets up a listening port on socekt 2 and handle text replies }
- function TFTPComponent.GetListeningPort : Integer;
- var
- Address1 ,
- Address2 ,
- Address3 ,
- Address4 : integer; { Address integer conversions }
- IPAddress : string; { IP Address holder }
- PortCommand : string; { Command holder }
- TheResult : Integer; { Result holder }
- TheReturnString : String; { ditto }
- begin
- { Set up any port on socket 2 }
- Socket2.PortName := '0';
- { Listen on a socket }
- Socket2.CCSockListen;
- { Get the IP Address of socket 1 and convert it to numbers }
- IPAddress := Socket1.GetSocketIPAddress( Socket1.TheSocket );
- Address1 := StrToInt( copy( IPAddress , 1 , Pos( '.' , IPAddress ) -1 ));
- IPAddress := copy( IPAddress , Pos( '.' , IPAddress ) + 1 , 255 );
- Address2 := StrToInt( copy( IPAddress , 1 , Pos( '.' , IPAddress) -1 ));
- IPAddress := copy( IPAddress , Pos( '.' , IPAddress ) + 1 , 255 );
- Address3 := StrToInt( copy( IPAddress , 1 , Pos( '.' , IPAddress ) -1 ));
- Address4 := StrToInt( copy( IPAddress , Pos( '.' , IPAddress ) + 1 , 255 ));
- { Turn it into a command and add socket 2 stuff }
- PortCommand := format( 'PORT %d,%d,%d,%d,%d,%d' ,
- [ Address1 , Address2 , Address3 , Address4 ,
- StrToInt( Socket2.GetSocketPort( Socket2.TheMasterSocket )) Shr 8,
- StrToInt( Socket2.GetSocketPort( Socket2.TheMasterSocket )) and $ff ]);
- { Put result in progress and status line }
- AddProgressText( PortCommand + #13#10 );
- ShowProgressText( PortCommand + #13#10 );
- TheResult := PerformFTPCommand( PortCommand , [nil] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := TCPIP_STATUS_FATAL_ERROR;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host Connection Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := TheResult;
- { leave }
- exit;
- end
- else
- begin
- { Return good result and leave }
- Result := TheResult;
- exit;
- end;
- end;
-
- { This function returns part of a unit text string }
- function TFTPComponent.GetUNIXTextString( var StringIn : String ) : String;
- var
- ReturnString : String;
- TheLength ,
- Counter_1 : integer;
- begin
- TheLength := Length( StringIn );
- if TheLength > 1 then
- begin
- for Counter_1 := 1 to TheLength do
- begin
- if StringIn[ Counter_1 ] = #10 then
- begin
- ReturnString := HolderLine;
- HolderLine := '';
- StringIn := Copy( StringIn , Counter_1 + 1 , 255 );
- Result := ReturnString;
- exit;
- end
- else
- begin
- if StringIn[ Counter_1 ] <> #0 then
- begin
- if StringIn[ Counter_1 ] <> #13 then
- HolderLine := HolderLine + StringIn[ Counter_1 ];
- end
- else
- begin
- Result := '';
- StringIn := '';
- end;
- end;
- end;
- end;
- Result := '';
- StringIn := '';
- end;
-
- procedure TFTPComponent.GetFileNameFromUNIXFileName( var TheName : String );
- var Counter_1 : Integer;
- ResultString : String;
- Finished : Boolean;
- begin
- if Pos( 'TOTAL' , Uppercase( TheName )) <> 0 then
- begin
- TheName := '';
- exit;
- end;
- Counter_1 := Length( TheName );
- ResultString := '';
- Finished := false;
- while not Finished do
- begin
- if TheName[ Counter_1 ] <> ' ' then
- begin
- Counter_1 := Counter_1 - 1;
- if Counter_1 = 0 then
- begin
- ResultString := TheName;
- Finished := true;
- end;
- end
- else
- begin
- Finished := true;
- ResultString := Copy( TheName , Counter_1 + 1 , 255 );
- end;
- end;
- TheName := ResultString;
- end;
-
- { This is the FTP components get remote directory listing into a list box }
- function TFTPComponent.GetRemoteDirectoryListing( TheListBox : TListBox )
- : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- InputString : String;
- Through ,
- Finished : Boolean;
- begin
- TheListBox.Clear;
- TheListbox.Tag := 2;
- TheListBox.Items.Add('..');
- Result := true;
- TheReturnString :=
- DoCStyleFormat( 'TYPE A' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'TYPE A',
- [ nil ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := true;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host Connection Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := true;
- { leave }
- exit;
- end
- else
- begin
- { Set up socket 2 for listening }
- Socket2.AsynchMode := False;
- Socket2.NonAsynchTimeoutValue := 60;
- { do a listen and send command to server that this is receipt socket }
- if GetListeningPort = TCPIP_STATUS_FATAL_ERROR then
- begin
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket1.NonAsynchTimeoutValue := 0; {infinite timeout}
- TheResult := PerformFTPCommand( 'LIST' , [nil] );
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- Socket1.NonAsynchTimeoutValue := 30;
- if (( TheResult = TCPIP_STATUS_RETRY_COMMAND ) or
- ( TheResult = TCPIP_STATUS_FATAL_ERROR )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not obtain remote directory!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Socket2.CCSockCancelListen;
- Result := true;
- exit;
- end;
- Socket2.CCSockAccept;
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not establish receive socket!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Result := true;
- exit;
- end;
- Through := false;
- repeat
- TheReturnString := Socket2.StringData;
- if Length( TheReturnString ) = 0 then Through := true;
- if Length( TheReturnString ) > 0 then
- begin
- finished := false;
- while not finished do
- begin
- InputString := GetUNIXTextString( TheReturnString );
- if InputString = '' then Finished := true else
- begin
- GetFileNameFromUNIXFileName( InputString);
- If InputString <> '' then
- TheListBox.Items.Add( InputString );
- end;
- end;
- end;
- if GlobalAbortedFlag then
- begin
- Socket1.OutOfBand := 'ABOR'+#13#10;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- result := true;
- exit;
- end;
- until Through;
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { cancel listening on second socket and close it }
- Socket2.CCSockCancelListen;
- Socket2.CCSockClose;
- end;
- FTPCommandInProgress := false;
- end;
-
- { This is the FTP components get remote directory listing into a list box }
- function TFTPComponent.GetRemoteDirectoryListingToMemo : Boolean;
- var TheReturnString : String; { Internal string holder }
- TheResult : Integer; { Internal int holder }
- Through : Boolean;
- begin
- Result := true;
- TheReturnString :=
- DoCStyleFormat( 'TYPE A' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { Send Password sequence }
- TheResult := PerformFTPCommand( 'TYPE A',
- [ nil ] );
- if TheResult <> TCPIP_STATUS_PRELIMINARY then
- begin
- Result := true;
- FTPCommandInProgress := false;
- exit;
- end;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- FTPCommandInProgress := false;
- if ( GlobalAbortedFlag or ( TheResult <> TCPIP_STATUS_COMPLETED )) then
- begin
- { Do clever C formatting trick }
- TheReturnString :=
- DoCStyleFormat( 'FTP Host Connection Failed!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- { Signal error }
- Result := true;
- { leave }
- exit;
- end
- else
- begin
- { Set up socket 2 for listening }
- Socket2.AsynchMode := False;
- Socket2.NonAsynchTimeoutValue := 30;
- { do a listen and send command to server that this is receipt socket }
- if GetListeningPort = TCPIP_STATUS_FATAL_ERROR then
- begin
- Socket2.CCSockCancelListen;
- exit;
- end;
- Socket1.NonAsynchTimeoutValue := 0; {infinite timeout}
- TheResult := PerformFTPCommand( 'LIST' , [nil] );
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- Socket1.NonAsynchTimeoutValue := 30;
- if (( TheResult = TCPIP_STATUS_RETRY_COMMAND ) or
- ( TheResult = TCPIP_STATUS_FATAL_ERROR )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not obtain remote directory!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Socket2.CCSockCancelListen;
- Result := true;
- exit;
- end;
- Socket2.CCSockAccept;
- if (( GlobalAbortedFlag ) or ( GlobalErrorCode <> 0 )) then
- begin
- TheReturnString :=
- DoCStyleFormat( 'Could not establish receive socket!' ,
- [ nil ] );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressErrorText( TheReturnString );
- Result := true;
- exit;
- end;
- Through := false;
- repeat
- TheReturnString := Socket2.StringData;
- if Length( TheReturnString ) = 0 then Through := true;
- if Length( TheReturnString ) > 0 then
- begin
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- end;
- if GlobalAbortedFlag then
- begin
- Socket1.OutOfBand := 'ABOR'+#13#10;
- repeat
- TheResult := GetFTPServerResponse( TheReturnString );
- { Put result in progress and status line }
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- until (( GlobalAbortedFlag ) or ( TheResult <> TCPIP_STATUS_PRELIMINARY ));
- result := true;
- exit;
- end;
- until Through;
- GetFTPServerResponse( TheReturnString );
- AddProgressText( TheReturnString );
- ShowProgressText( TheReturnString );
- { cancel listening on second socket and close it }
- Socket2.CCSockCancelListen;
- Socket2.CCSockClose;
- end;
- end;
-
- { This is the FTP components get local directory listing into a list box }
- function TFTPComponent.GetLocalDirectoryAndListing( var TheString : String;
- TheListBox : TListBox )
- : Boolean;
- var TheFLB : TFileListBox;
- begin
- { Get the working directory }
- GetDir( 0 , TheString );
- { Clear incoming LB }
- TheListBox.Clear;
- TheListBox.Tag := 2;
- TheFLB := TFileListBox.Create( Application.MainForm );
- TheFLB.Visible := false;
- TheFLB.Parent := Application.MainForm;
- TheFLB.FileType := [ ftNormal , ftDirectory ];
- TheFLB.Directory := TheString;
- TheFLB.Update;
- TheListBox.Items.Assign( TheFLB.Items );
- TheFLB.Free;
- result := true;
- end;
-
- { This is a clever c-style formatting trick }
- function TFTPComponent.DoCStyleFormat(
- TheText : string;
- const TheArguments : array of const ) : String;
- begin
- Result := Format( TheText , TheArguments ) + #13#10;
- end;
-
- function TFTPComponent.GetQuotedString( TheString : String ) : String;
- var TheIndex : Integer; { Holder var }
- ResultString : String; { ditto }
- begin
- { Find out if " present at all }
- TheIndex := Pos( '"' , TheString );
- If TheIndex = 0 then
- begin
- { If not, return null string and exit }
- Result := '';
- exit;
- end
- else
- begin
- { Get from first " to end of string in holder }
- ResultString := Copy( TheString , TheIndex + 1 , 255 );
- { Find position to second " }
- TheIndex := Pos( '"' , ResultString );
- { If no ending " then return whole string and leave }
- if TheIndex = 0 then
- begin
- Result := ResultString;
- exit;
- end
- else
- begin
- { Get internal text between quotes and exit }
- ResultString := Copy( ResultString , 1 , TheIndex - 1 );
- Result := ResultString;
- end;
- end;
- end;
-
- procedure TCCINetCCForm.UpdateGauge( BytesFinished , TotalToHandle : longint );
- var
- Percentage : longint;
- begin
- if BytesFinished > TotalToHandle then BytesFinished := TotalToHandle;
- if TotalToHandle = 0 then exit;
- Percentage := Trunc( 100.0 / ( TotalToHandle / BytesFinished ));
- Gauge1.Progress := Percentage;
- Panel1.Caption := ' Status: ' + IntToStr( BytesFinished ) +
- ' bytes ' + FileNameToXFer + ' (' + IntToStr( Percentage ) + '% Done)';
- end;
-
- procedure TCCINetCCForm.UpdateMailGauge( BytesFinished , TotalToHandle : longint );
- var
- Percentage : longint;
- begin
- if BytesFinished > TotalToHandle then BytesFinished := TotalToHandle;
- if TotalToHandle = 0 then exit;
- Percentage := Trunc( 100.0 / ( TotalToHandle / BytesFinished ));
- Gauge1.Progress := Percentage;
- Panel1.Caption := ' Status: ' + IntToStr( BytesFinished ) +
- ' bytes mail (' + IntToStr( Percentage ) + '% Done)';
- end;
-
- procedure TCCINetCCForm.UpdateMIMEGauge( BytesFinished , TotalToHandle : longint );
- var
- Percentage : longint;
- begin
- if BytesFinished > TotalToHandle then BytesFinished := TotalToHandle;
- if TotalToHandle = 0 then exit;
- Percentage := Trunc( 100.0 / ( TotalToHandle / BytesFinished ));
- Gauge1.Progress := Percentage;
- Panel1.Caption := ' Status: ' + IntToStr( BytesFinished ) +
- ' bytes MIME (' + IntToStr( Percentage ) + '% Done)';
- end;
-
- procedure TCCINetCCForm.UpdateUUGauge( BytesFinished , TotalToHandle : longint );
- var
- Percentage : longint;
- begin
- if BytesFinished > TotalToHandle then BytesFinished := TotalToHandle;
- if TotalToHandle = 0 then exit;
- Percentage := Trunc( 100.0 / ( TotalToHandle / BytesFinished ));
- Gauge1.Progress := Percentage;
- Panel1.Caption := ' Status: ' + IntToStr( BytesFinished ) +
- ' bytes UUCode (' + IntToStr( Percentage ) + '% Done)';
- Panel1.Show;
- end;
-
- { This procedure actually attempts to connect to the internet at an ftp site }
- function TCCINetCCForm.DoFTPConnection( PCRPointer : PConnectionsRecord ) : boolean;
- var TheReturnString : String; { Display results of connection in status lines }
- begin
- { Create the component }
- Result := false;
- { Do busy cursors }
- SetHGCursors;
- if not TheFTPComponent.EstablishConnection( PCRPointer ) then
- begin
- { Do saved cursors }
- TheFTPComponent.FTPCommandInProgress := false;
- TheFTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end
- else
- begin { Connected; continue login process }
- if not TheFTPComponent.LoginUser( PCRPointer ) then
- begin
- { Do saved cursors }
- TheFTPComponent.FTPCommandInProgress := false;
- TheFTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end;
- if not TheFTPComponent.SendPassword( PCRPointer ) then
- begin
- { Do saved cursors }
- TheFTPComponent.FTPCommandInProgress := false;
- TheFTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end;
- if not TheFTPComponent.SetRemoteStartupDirectory( PCRPointer ) then
- begin
- { Do saved cursors }
- SetNormalCursors;
- TheFTPComponent.Connection_Established := false;
- TheFTPComponent.FTPCommandInProgress := false;
- exit;
- end;
- if not TheFTPComponent.GetRemoteWorkingDirectory( TheReturnString ) then
- begin
- { Do saved cursors }
- TheFTPComponent.Connection_Established := false;
- TheFTPComponent.FTPCommandInProgress := false;
- SetNormalCursors;
- exit;
- end;
- { Put up remote directory via PWD and strip quotes }
- Label4.Caption := TheFTPComponent.GetQuotedString( TheReturnString );
- { Get the listings of directories and exit OK }
- TheFTPComponent.GetRemoteDirectoryListing( Listbox1 );
- TheFTPComponent.GetLocalDirectoryAndListing( TheReturnString ,
- Listbox2 );
- if Label5.Canvas.TextWidth( TheReturnString ) > Label5.Width then
- TheReturnString := TheFTPComponent.GetShortPathName( TheReturnString );
- Label5.Caption := TheReturnString;
- SetNormalCursors;
- Result := true;
- EnableFTPMenus;
- TheFTPComponent.FTPCommandInProgress := false;
- Panel1.Caption := ' Status : Connected to ' + PCRPointer^.CIPAddress;
- end;
- end;
-
- { This procedure actually attempts to connect to the internet at an nntp site }
- function TCCINetCCForm.DoNNTPConnection( PCRPointer : PConnectionsRecord ) : boolean;
- begin
- { Create the component }
- Result := false;
- { Do busy cursors }
- SetHGCursors;
- if not TheNNTPComponent.EstablishConnection( PCRPointer ) then
- begin
- { Do saved cursors }
- TheNNTPComponent.NNTPCommandInProgress := false;
- TheNNTPComponent.Connection_Established := false;
- SetNormalCursors;
- exit;
- end
- else
- begin { Connected; continue login process }
- SetNormalCursors;
- Result := true;
- EnableNNTPMenus;
- TheNNTPComponent.NNTPCommandInProgress := false;
- Panel1.Caption := ' Status : Connected to ' + PCRPointer^.CIPAddress;
- end;
- end;
-
- { This procedure actually attempts to disconnect to the internet at an ftp site}
- procedure TCCINetCCForm.DoFTPDisconnect;
- begin
- { Call QUIT command }
- TheFTPComponent.Disconnect;
- { Kill the socket }
- TheFTPComponent.Socket1.CCSockClose;
- end;
-
- { This procedure actually attempts to disconnect to the internet at an ftp site}
- procedure TCCINetCCForm.DoNNTPDisconnect;
- begin
- { Call QUIT command }
- TheNNTPComponent.Disconnect;
- { Kill the socket }
- TheNNTPComponent.Socket1.CCSockClose;
- end;
-
- { This procedure reads in the ini file and default path info }
- procedure TCCINetCCForm.ReadIniData;
- begin
- TheICCIniFile := TIniFile.Create( 'CCICC.INI' );
- MailPath := TheICCIniFile.ReadString( 'Paths','MailPath','C:\WINDOWS' );
- NewsPath := TheICCIniFile.ReadString( 'Paths','NewsPath','C:\WINDOWS' );
- FTPPath := TheICCIniFile.ReadString( 'Paths','FTPPath','C:\WINDOWS' );
- PasswordControlVector := TheICCIniFile.ReadInteger( 'Vectors','PWControl',2 );
- DefaultDownloadVector := TheICCIniFile.ReadInteger( 'Vectors','DefDL', 3 );
- TheAnonRedialVector := TheICCIniFile.ReadInteger( 'Vectors','AnonRD', 20 );
- NewsReadArticlePurgingVector := TheICCIniFile.ReadInteger( 'Vectors','NewsPurge', 1 );
- NewsPostQueueingVector := TheICCIniFile.ReadInteger( 'Vectors','NewsQueue', 1 );
- NewsReadArticleDisplayVector := TheICCIniFile.ReadInteger( 'Vectors','NewsRDisp', 1 );
- NewsUUMIMEVector := TheICCIniFile.ReadInteger( 'Vectors','NewsUUMIME', 2 );
- NewsInitialUpdateVector := TheICCIniFile.ReadInteger( 'Vectors','NewsInitUD', 1 );
- EMPasswordControlVector := TheICCIniFile.ReadInteger( 'Vectors','EMPWControl', 1 );
- EMRemoteDeletionVector := TheICCIniFile.ReadInteger( 'Vectors','EMRemDel', 2 );
- EMChokeVector := TheICCIniFile.ReadInteger( 'Vectors','EMChoke', 1 );
- EMDefaultDownloadVector := TheICCIniFile.ReadInteger( 'Vectors','EMInitUD', 1 );
- EMQueueVector := TheICCIniFile.ReadInteger( 'Vectors','EMQueue', 1 );
- TheICCIniFile.Free;
- end;
-
- { This procedure writes out default path data to the ini file }
- procedure TCCINetCCForm.WriteIniData;
- begin
- TheICCIniFile := TIniFile.Create( 'CCICC.INI' );
- TheICCIniFile.WriteString( 'Paths','MailPath', MailPath );
- TheICCIniFile.WriteString( 'Paths','NewsPath', NewsPath );
- TheICCIniFile.WriteString( 'Paths','FTPPath', FTPPath );
- TheICCIniFile.WriteInteger( 'Vectors','PWControl', PasswordControlVector );
- TheICCIniFile.WriteInteger( 'Vectors','DefDL', DefaultDownloadVector );
- TheICCIniFile.WriteInteger( 'Vectors','AnonRD', TheAnonRedialVector );
- TheICCIniFile.WriteInteger( 'Vectors','NewsPurge',
- NewsReadArticlePurgingVector );
- TheICCIniFile.WriteInteger( 'Vectors','NewsQueue', NewsPostQueueingVector );
- TheICCIniFile.WriteInteger( 'Vectors','NewsRDisp',
- NewsReadArticleDisplayVector );
- TheICCIniFile.WriteInteger( 'Vectors','NewsUUMIME', NewsUUMIMEVector );
- TheICCIniFile.WriteInteger( 'Vectors','NewsInitUD', NewsInitialUpdateVector );
- TheICCIniFile.WriteInteger( 'Vectors','EMPWControl', EMPasswordControlVector );
- TheICCIniFile.WriteInteger( 'Vectors','EMRemDel', EMRemoteDeletionVector );
- TheICCIniFile.WriteInteger( 'Vectors','EMChoke', EMChokeVector );
- TheICCIniFile.WriteInteger( 'Vectors','EMInitUD', EMDefaultDownloadVector );
- TheICCIniFile.WriteInteger( 'Vectors','EMQueue', EMQueueVector );
- TheICCIniFile.Free;
- end;
-
- { Procedure to load the FTP Site list }
- procedure TCCINetCCForm.LoadFTPSiteFile;
- var TheTCRecord : PConnectionsRecord; { Generic TCR Pointer }
- FTPSLName : String; { FTP Site List filename }
- Counter_1 : Integer; { Loop counter }
- begin
- { Create the sites list list }
- TheFTPSiteList := TList.Create;
- { Set up the FTP sites list file name }
- FTPSLName := FTPPath + '\FTPSITES.TCR';
- { If the FTP Site List exists load it in }
- if FileExists( FTPSLName ) then
- begin
- { set up the file and open it }
- AssignFile( TheFTPSiteFile , FTPSLName );
- Reset( TheFTPSiteFile );
- { read in the records }
- for Counter_1 := 0 to FileSize( TheFTPSiteFile ) - 1 do
- begin
- { Create the TCRecord }
- New( TheTCRecord );
- { Read in the data record }
- Seek( TheFTPSiteFile , Counter_1 );
- Read( TheFTPSiteFile , TheTCRecord^ );
- { Add the record to the list }
- TheFTPSiteList.Add( TheTCRecord );
- end;
- { close the file }
- CloseFile( TheFTPSiteFile );
- end
- else
- { Otherwise create a default one with a few anonymous sites }
- begin
- { create new record }
- New( TheTCRecord );
- { fill in its info }
- with TheTCRecord^ do
- begin
- CProfile := 'Winsite Windows Archive';
- CIPAddress := 'ftp.winsite.com';
- CUserName := 'anonymous';
- CPassword := 'guest@nowhere.com';
- CStartDir := '/pub';
- end;
- { add it to the list }
- { do it three more times }
- TheFTPSiteList.Add( TheTCRecord );
- New( TheTCRecord );
- with TheTCRecord^ do
- begin
- CProfile := 'Digital Equipment Corp';
- CIPAddress := 'gatekeeper.dec.com';
- CUserName := 'anonymous';
- CPassword := 'guest@nowhere.com';
- CStartDir := '/pub';
- end;
- TheFTPSiteList.Add( TheTCRecord );
- New( TheTCRecord );
- with TheTCRecord^ do
- begin
- CProfile := 'Microsoft FTP Site';
- CIPAddress := 'ftp.microsoft.com';
- CUserName := 'anonymous';
- CPassword := 'guest@nowhere.com';
- CStartDir := '/pub';
- end;
- TheFTPSiteList.Add( TheTCRecord );
- New( TheTCRecord );
- with TheTCRecord^ do
- begin
- CProfile := 'Oakland MSDOS Archive';
- CIPAddress := 'oak.oakland.edu';
- CUserName := 'anonymous';
- CPassword := 'guest@nowhere.com';
- CStartDir := '/pub';
- end;
- TheFTPSiteList.Add( TheTCRecord );
- { create the file and write out the data, then close it }
- AssignFile( TheFTPSiteFile , FTPSLName );
- Rewrite( TheFTPSiteFile );
- for Counter_1 := 0 to 3 do
- begin
- TheTCRecord :=
- PConnectionsRecord( TheFTPSiteList.Items[ Counter_1 ] );
- Seek( TheFTPSiteFile , Counter_1 );
- Write( TheFTPSiteFile , TheTCRecord^ );
- end;
- CloseFile( TheFTPSiteFile );
- end;
- { Create the working copy for use to make safe changes in info dlg }
- TheWorkingFTPSL := TList.Create;
- For Counter_1 := 0 to TheFTPSiteList.Count - 1 do
- begin
- New( TheTCRecord );
- TheTCRecord^ := PConnectionsRecord( TheFTPSiteList.Items[ Counter_1 ] )^;
- TheWorkingFTPSL.Add( TheTCRecord );
- end;
- end;
-
- { Procedure to load the NNTP Site list }
- procedure TCCINetCCForm.LoadNNTPSiteFile;
- var TheNGRecord : PConnectionsRecord; { Generic TCR Pointer }
- NNTPSLName : String; { NNTP Site List filename }
- Counter_1 : Integer; { Loop counter }
- begin
- { Create the sites list list }
- TheNewsServerList := TList.Create;
- { Set up the FTP sites list file name }
- NNTPSLName := NewsPath + '\NNTPSITE.TCR';
- { If the FTP Site List exists load it in }
- if FileExists( NNTPSLName ) then
- begin
- { set up the file and open it }
- AssignFile( TheNewsServerFile , NNTPSLName );
- Reset( TheNewsServerFile );
- { read in the records }
- for Counter_1 := 0 to FileSize( TheNewsServerFile ) - 1 do
- begin
- { Create the TCRecord }
- New( TheNGRecord );
- { Read in the data record }
- Seek( TheNewsServerFile , Counter_1 );
- Read( TheNewsServerFile , TheNGRecord^ );
- { Add the record to the list }
- TheNewsServerList.Add( TheNGRecord );
- end;
- { close the file }
- CloseFile( TheNewsServerFile );
- end
- else
- { Otherwise create a default one with a generic news site (?) }
- begin
- { create new record }
- New( TheNGRecord );
- { fill in its info }
- with TheNGRecord^ do
- begin
- CProfile := 'My News Server';
- CIPAddress := 'news.myprovider.com';
- CUserName := '';
- CPassword := '';
- CStartDir := '';
- end;
- { add it to the list }
- { do it three more times }
- TheNewsServerList.Add( TheNGRecord );
- { create the file and write out the data, then close it }
- AssignFile( TheNewsServerFile , NNTPSLName );
- Rewrite( TheNewsServerFile );
- TheNGRecord :=
- PConnectionsRecord( TheNewsServerList.Items[ 0 ] );
- Seek( TheNewsServerFile , 0 );
- Write( TheNewsServerFile , TheNGRecord^ );
- CloseFile( TheNewsServerFile );
- end;
- TheWorkingNSSL := TList.Create;
- For Counter_1 := 0 to TheNewsServerList.Count - 1 do
- begin
- New( TheNGRecord );
- TheNGRecord^ := PConnectionsRecord( TheNewsServerList.Items[ Counter_1 ] )^;
- TheWorkingNSSL.Add( TheNGRecord );
- end;
- end;
-
- { This procedure saves off the FTP Site List }
- procedure TCCINetCCForm.SaveFTPSiteFile;
- var TheTCRecord : PConnectionsRecord; { The TC Record pointer }
- FTPSLName : String; { FTP Site List filename }
- Counter_1 : Integer; { Loop counter }
- begin
- { Set up the file name }
- FTPSLName := FTPPath + '\FTPSITES.TCR';
- { Assign the file }
- AssignFile( TheFTPSiteFile , FTPSLName );
- { Rewrite it }
- Rewrite( TheFTPSiteFile );
- { run the list through the procedure }
- for Counter_1 := 0 to TheFTPSiteList.Count - 1 do
- begin
- { get the record from the list }
- TheTCRecord :=
- PConnectionsRecord( TheFTPSiteList.Items[ Counter_1 ] );
- { Do the seek/write }
- Seek( TheFTPSiteFile , Counter_1 );
- Write( TheFTPSiteFile , TheTCRecord^ );
- { free the record }
- Dispose( TheTCRecord );
- end;
- { Close the file }
- CloseFile( TheFTPSiteFile );
- { Free the list pointers }
- TheFTPSiteList.Free;
- TheWorkingFTPSL.Free;
- end;
-
- { This procedure saves off the FTP Site List }
- procedure TCCINetCCForm.SaveNNTPSiteFile;
- var TheNGRecord : PConnectionsRecord; { The TC Record pointer }
- NNTPSLName : String; { NNTP Site List filename }
- Counter_1 : Integer; { Loop counter }
- begin
- { Set up the file name }
- NNTPSLName := NewsPath + '\NNTPSITE.TCR';
- { Assign the file }
- AssignFile( TheNewsServerFile , NNTPSLName );
- { Rewrite it }
- Rewrite( TheNewsServerFile );
- { run the list through the procedure }
- for Counter_1 := 0 to TheNewsServerList.Count - 1 do
- begin
- { get the record from the list }
- TheNGRecord :=
- PConnectionsRecord( TheNewsServerList.Items[ Counter_1 ] );
- { Do the seek/write }
- Seek( TheNewsServerFile , Counter_1 );
- Write( TheNewsServerFile , TheNGRecord^ );
- { free the record }
- Dispose( TheNGRecord );
- end;
- { Close the file }
- CloseFile( TheNewsServerFile );
- { Free the list pointers }
- TheNewsServerList.Free;
- TheWorkingNSSL.Free;
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupFTPSiteLists;
- var Counter_1 : Integer; { Loop counter }
- begin
- { Set up display for main form }
- CCINetCCForm.Tag := 2;
- CCINetCCForm.Caption := 'CC Internet Command Center -- FTP Mode';
- CCINetCCForm.ViewWinsockInfo1.Enabled := false;
- CCINetCCForm.FTP1.Enabled := false;
- CCINetCCForm.FTP2.Enabled := true;
- CCINetCCForm.Label1.Caption := 'FTP Site:';
- CCINetCCForm.Button1.Caption := 'Connect';
- CCINetCCForm.Label4.Caption := 'Local Dir';
- CCINetCCForm.Label5.Caption := 'Remote Dir';
- { Set tag for FTP stuff }
- CCICInfoDlg.Tag := 2;
- { set up caption of main label }
- CCICInfoDlg.Label2.Caption := 'FTP Sites';
- { hide outline panel }
- CCICInfoDlg.Panel6.Visible := false;
- { clear the list box }
- CCICInfoDlg.ListBox2.Clear;
- CCINetCCForm.ComboBox1.Clear;
- { add profile strings to the list box }
- for Counter_1 := 0 to TheFTPSiteList.Count - 1 do
- begin
- CCICInfoDlg.ListBox2.Items.Add( PConnectionsRecord(
- TheFTPSiteList.Items[ Counter_1 ] )^.CProfile );
- CCINetCCForm.ComboBox1.Items.Add( PConnectionsRecord(
- TheFTPSiteList.Items[ Counter_1 ] )^.CProfile );
- end;
- { Set up caption of special button }
- CCICInfoDlg.Button1.Caption := 'Anonymous Login';
- { Start with top record }
- CCICInfoDlg.ListBox2.ItemIndex := 0;
- CCINetCCForm.ComboBox1.ItemIndex := 0;
- { put in data from top record and reset captions }
- with PConnectionsRecord( TheFTPSiteList.Items[ 0 ] )^ do
- begin
- with CCICInfoDlg do
- begin
- Edit1.Text := CProfile;
- Panel2.Caption := ' Name:';
- Edit2.Text := CIPAddress;
- Panel3.Caption := ' IP Address:';
- Edit3.Text := CUserName;
- Panel5.Caption := ' User Name:';
- case PasswordControlVector of
- 1 : Edit4.Text := CPassword;
- 2 : Edit4.Text := '**********';
- end;
- Panel8.Caption := ' Password:';
- Edit5.Text := CStartDir;
- Panel9.Caption := ' Starting Dir:';
- end;
- end;
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupNNTPSiteLists;
- begin
- { Set up display for main form }
- CCINetCCForm.Tag := 4; { Usenet News Tag }
- CCINetCCForm.Caption := 'CC Internet Command Center -- Usenet News Mode';
- CCINetCCForm.ViewWinsockInfo1.Enabled := false;
- CCINetCCForm.FTP1.Enabled := true;
- CCINetCCForm.FTP2.Enabled := false;
- CCINetCCForm.UsenetNws1.Enabled := false;
- CCINetCCForm.News1.Enabled := true;
- CCINetCCForm.Label1.Caption := 'NNTP Server:';
- CCINetCCForm.Button1.Caption := 'Connect';
- CCINetCCForm.Label4.Caption := 'SubScribed Groups';
- CCINetCCForm.Label5.Caption := 'Unread Articles';
- { Create the working copy for use to make safe changes in info dlg }
- end;
-
- { This method saves off the Newsgroup and Article Lists }
- procedure TCCINetCCForm.SaveNNTPNewsGroupLists;
- var TheNGRecord : PNewsGroupRecord; { Generic NGR Pointer }
- TheNGARecord : PNewsGroupArticleRecord; { }
- WorkingList : TList;
- Counter_1 ,
- Counter_2 : Integer; { Loop counter }
- NNTPNGLName , { NewsGroup Articles fname }
- NNTPARName : String; { NNTP NewsRC filename }
- begin
- { Abort if no server to select }
- if ComboBox1.ItemIndex = -1 then exit;
- { Get number of server in list }
- WhichServer := ComboBox1.ItemIndex;
- { Set up the FTP sites list file name }
- NNTPNGLName := NewsPath + '\NEWSRC ' + IntToStr( WhichServer ) + '.NRC';
- { If the FTP Site List exists load it in }
- { set up the file and open it }
- AssignFile( TheNewsRCFile , NNTPNGLName );
- ReWrite( TheNewsRCFile );
- { read in the records }
- for Counter_1 := 0 to TheNewsRCList.Count - 1 do
- begin
- { Create the TCRecord }
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] );
- { Read in the data record }
- Seek( TheNewsRCFile , Counter_1 );
- Write( TheNewsRCFile , TheNGRecord^ );
- { Add the record to the list }
- WorkingList := TList( TheNGRecord^.GLTag );
- if WorkingList.Count > 0 then
- begin
- NNTPARName := TheNGRecord^.GFileName;
- TheNGArticlesList := TList.Create;
- AssignFile( TheNewsArticleFile , NewsPath + '\' + NNTPARName );
- ReWrite( TheNewsArticleFile );
- for Counter_2 := 0 to WorkingList.Count - 1 do
- begin
- TheNGARecord :=
- PNewsGroupArticleRecord( WorkingList.Items[ Counter_2 ] );
- Seek( TheNewsArticleFile , Counter_2 );
- Write( TheNewsArticleFile , TheNGARecord^ );
- Dispose( TheNGARecord );
- end;
- CloseFile( TheNewsArticleFile );
- end;
- WorkingList.Free;
- Dispose( TheNGRecord );
- end;
- { close the file }
- CloseFile( TheNewsRCFile );
- { Free the list itself }
- TheNewsRCList.Free;
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupNNTPNewsGroupLists;
- var TheNGRecord : PNewsGroupRecord; { Generic NGR Pointer }
- TheNGARecord : PNewsGroupArticleRecord; { }
- Counter_1 ,
- Counter_2 : Integer; { Loop counter }
- NNTPNGLName , { NewsGroup Articles fname }
- NNTPARName : String; { NNTP NewsRC filename }
- begin
- { Abort if no server to select }
- if ComboBox1.ItemIndex = -1 then exit;
- { Get number of server in list }
- WhichServer := ComboBox1.ItemIndex;
- { Create the sites list list }
- TheNewsRCList := TList.Create;
- { Set up the FTP sites list file name }
- NNTPNGLName := NewsPath + '\NEWSRC ' + IntToStr( WhichServer ) + '.NRC';
- { If the FTP Site List exists load it in }
- if FileExists( NNTPNGLName ) then
- begin
- { set up the file and open it }
- AssignFile( TheNewsRCFile , NNTPNGLName );
- Reset( TheNewsRCFile );
- { read in the records }
- for Counter_1 := 0 to FileSize( TheNewsRCFile ) - 1 do
- begin
- { Create the TCRecord }
- New( TheNGRecord );
- { Read in the data record }
- Seek( TheNewsRCFile , Counter_1 );
- Read( TheNewsRCFile , TheNGRecord^ );
- { Add the record to the list }
- TheNewsRCList.Add( TheNGRecord );
- end;
- { close the file }
- CloseFile( TheNewsRCFile );
- end
- else
- { Otherwise create a default one with 3 delphi newsgroups }
- begin
- { create new record }
- New( TheNGRecord );
- { fill in its info }
- with TheNGRecord^ do
- begin
- GName := 'Delphi Comps';
- GRealName := 'comp.lang.pascal.delphi.components';
- GLowest := 0;
- GHighest := 0;
- GPostable := true;
- GSubscribed := true;
- GTotalArticles := 0;
- GTotalAvailable := 0;
- GLowestAvailable := 0;
- GHighestAvailable := 0;
- GTotalUnReadArticles := 0;
- GIDNumber := 1;
- GFileName := 'NL' + IntToStr( WhichServer ) + 'G1.NGR';
- GLTag := 0;
- end;
- { add it to the list }
- TheNewsRCList.Add( TheNGRecord );
- { create new record }
- New( TheNGRecord );
- { fill in its info }
- with TheNGRecord^ do
- begin
- GName := 'Delphi DB';
- GRealName := 'comp.lang.pascal.delphi.databases';
- GLowest := 0;
- GHighest := 0;
- GPostable := true;
- GSubscribed := true;
- GTotalArticles := 0;
- GTotalAvailable := 0;
- GLowestAvailable := 0;
- GHighestAvailable := 0;
- GTotalUnReadArticles := 0;
- GIDNumber := 2;
- GFileName := 'NL' + IntToStr( WhichServer ) + 'G2.NGR';
- GLTag := 0;
- end;
- { add it to the list }
- TheNewsRCList.Add( TheNGRecord );
- { create new record }
- New( TheNGRecord );
- { fill in its info }
- with TheNGRecord^ do
- begin
- GName := 'Delphi Misc';
- GRealName := 'comp.lang.pascal.delphi.misc';
- GLowest := 0;
- GHighest := 0;
- GPostable := true;
- GSubscribed := true;
- GTotalArticles := 0;
- GTotalAvailable := 0;
- GLowestAvailable := 0;
- GHighestAvailable := 0;
- GTotalUnReadArticles := 0;
- GIDNumber := 3;
- GFileName := 'NL' + IntToStr( WhichServer ) + 'G3.NGR';
- GLTag := 0;
- end;
- { add it to the list }
- TheNewsRCList.Add( TheNGRecord );
- { create the file and write out the data, then close it }
- AssignFile( TheNewsRCFile , NNTPNGLName );
- Rewrite( TheNewsRCFile );
- for Counter_1 := 0 to 2 do
- begin
- TheNGRecord :=
- PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] );
- Seek( TheNewsRCFile , Counter_1 );
- Write( TheNewsRCFile , TheNGRecord^ );
- end;
- CloseFile( TheNewsRCFile );
- end;
- { Load in Articles Records and create storage lists }
- for Counter_1 := 0 to TheNewsRCList.Count - 1 do
- begin
- NNTPARName := PNewsGroupRecord(
- TheNewsRCList.Items[ Counter_1 ] )^.GFileName;
- if FileExists( NewsPath + '\' + NNTPARName ) then
- begin
- TheNGArticlesList := TList.Create;
- AssignFile( TheNewsArticleFile , NewsPath + '\' + NNTPARName );
- Reset( TheNewsArticleFile );
- for Counter_2 := 0 to FileSize( TheNewsArticleFile ) - 1 do
- begin
- New( TheNGARecord );
- Seek( TheNewsArticleFile , Counter_2 );
- Read( TheNewsArticleFile , TheNGARecord^ );
- TheNGArticlesList.Add( TheNGARecord );
- end;
- CloseFile( TheNewsArticleFile );
- PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] )^.GLTag :=
- Longint( TheNGArticlesList );
- end
- else
- begin
- TheNGArticlesList := TList.Create;
- PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] )^.GLTag :=
- Longint( TheNGArticlesList );
- end;
- end;
- { Create working Newsgroup list for later }
- TheWorkingNRCSL := TList.Create;
- For Counter_1 := 0 to TheNewsRCList.Count - 1 do
- begin
- New( TheNGRecord );
- TheNGRecord^ := PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] )^;
- TheWorkingNRCSL.Add( TheNGRecord );
- end;
- end;
-
- { This procedure populates LB2 with article subjects for any }
- { available articles for a given newsgroup. }
- procedure TCCINetCCForm.PopulateLB2WithArticleHeaders;
- var Counter_1 : Integer;
- TheNGARecord : PNewsGroupArticleRecord;
- TempString : String;
- begin
- { Clear target list box }
- ListBox2.Clear;
- for Counter_1 := 0 to TheNGArticlesList.Count - 1 do
- begin
- TheNGARecord :=
- PNewsGroupArticleRecord( TheNGArticlesList.Items[ Counter_1 ] );
- TempString := ' [' + IntToStr( Counter_1 ) + '] ' +
- TheNGARecord^.NGASubject;
- if TheNGARecord^.NGADownloaded then TempString[ 1 ] :=
- 'D';
- if TheNGARecord^.NGARead then TempString[ 3 ] := 'R';
- if TheNGARecord^.NGAPosted then TempString[ 3 ] := 'S';
- ListBox2.Items.Add( TempString );
- end;
- end;
-
- { This procedure swaps in the list of subscribed newsgroups to LB1 }
- { and calls another procedure to populate LB2 with any available }
- { articles for the newsgroup. }
- procedure TCCINetCCForm.SetupNewsGroupListboxes;
- var Counter_1 : Integer;
- TempString : String;
- TheNGRecord : PNewsGroupRecord;
- begin
- ListBox1.Clear;
- ListBox1.Tag := 5;
- ListBox2.Tag := 5;
- Label4.Caption := 'NewsGroups';
- Label5.Caption := 'Articles';
- if TheNewsRCList.Count = 0 then
- begin
- ListBox2.Clear;
- exit;
- end;
- ComboBox1.Clear;
- for Counter_1 := 0 to TheNewsRCList.Count - 1 do
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] );
- TempString := TheNGRecord^.GName;
- ComboBox1.Items.Add( TheNGRecord^.GRealName );
- if TheNGRecord^.GSubscribed then
- TempString := '[S] ' + TempString else TempString := '[U] ' + TempString;
- TempString := TempString + '{' + IntToStr( TheNGRecord^.GTotalNew ) + '}';
- ListBox1.Items.Add( TempString );
- end;
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ 0 ] );
- TheNGArticlesList := TList( TheNGRecord^.GLTag );
- PopulateLB2WithArticleHeaders;
- Label1.Caption := 'NewsGroup:';
- ComboBox1.ItemIndex := 0;
- Button1.Caption := 'DL Article(s)';
- Tag := 5; { Set download vector }
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupNNTPServersInfoDisplay;
- var Counter_1 : Integer; { Loop counter }
- begin
- { Set tag for NNTP stuff }
- CCICInfoDlg.Tag := 4; { Usenet News Tag -- servers }
- { set up caption of main label }
- CCICInfoDlg.Label2.Caption := 'News Server Sites';
- { hide outline panel }
- CCICInfoDlg.Panel6.Visible := false;
- CCICInfoDlg.Panel5.Visible := false;
- CCICInfoDlg.Panel8.Visible := false;
- CCICInfoDlg.Panel9.Visible := false;
- { clear the list box }
- CCICInfoDlg.ListBox2.Clear;
- CCINetCCForm.ComboBox1.Clear;
- { add profile strings to the list box }
- for Counter_1 := 0 to TheNewsServerList.Count - 1 do
- begin
- CCICInfoDlg.ListBox2.Items.Add( PConnectionsRecord(
- TheNewsServerList.Items[ Counter_1 ] )^.CProfile );
- CCINetCCForm.ComboBox1.Items.Add( PConnectionsRecord(
- TheNewsServerList.Items[ Counter_1 ] )^.CProfile );
- end;
- { Set up caption of special button }
- CCICInfoDlg.Button1.Visible := false;
- { Start with top record }
- CCICInfoDlg.ListBox2.ItemIndex := 0;
- CCINetCCForm.ComboBox1.ItemIndex := 0;
- { put in data from top record and reset captions }
- with PConnectionsRecord( TheNewsServerList.Items[ 0 ] )^ do
- begin
- with CCICInfoDlg do
- begin
- Edit1.Text := CProfile;
- Panel2.Caption := ' Name:';
- Edit2.Text := CIPAddress;
- Panel3.Caption := ' IP Address:';
- end;
- end;
- end;
-
- { This procedure switches in the FTP sites list to the info dlg and main cbox }
- procedure TCCINetCCForm.SetupNNTPNewsGroupsInfoDisplay;
- var Counter_1 : Integer; { Loop counter }
- WorkingFileName : String;
- TheWorkingSL : TStringList;
- begin
- { Set tag for NNTP stuff }
- CCICInfoDlg.Tag := 5; { Usenet News Tag -- newsgroups }
- { set up caption of main label }
- CCICInfoDlg.Label2.Caption := 'Active NewsGroups';
- { hide outline panel }
- CCICInfoDlg.Panel5.Visible := true;
- CCICInfoDlg.Panel6.Visible := true;
- CCICInfoDlg.Panel6.Height := 224;
- CCICInfoDlg.Panel6.Top := 120;
- CCICInfoDlg.Label1.Caption := 'Available NewsGroups';
- CCICInfoDlg.Panel8.Visible := false;
- CCICInfoDlg.Panel9.Visible := false;
- { clear the list box }
- CCICInfoDlg.ListBox2.Clear;
- { add profile strings to the list box }
- for Counter_1 := 0 to TheNewsRCList.Count - 1 do
- begin
- CCICInfoDlg.ListBox2.Items.Add( PNewsGroupRecord(
- TheNewsRCList.Items[ Counter_1 ] )^.GName );
- end;
- { Set up caption of special button }
- CCICInfoDlg.Button1.Visible := true;
- CCICInfoDlg.Button1.Caption := 'Toggle Subscription';
- { Start with top record }
- CCICInfoDlg.ListBox2.ItemIndex := 0;
- { put in data from top record and reset captions }
- with PNewsGroupRecord( TheNewsRCList.Items[ 0 ] )^ do
- begin
- with CCICInfoDlg do
- begin
- Edit1.Text := GName;
- Panel2.Caption := 'NG Name:';
- Edit2.Text := GRealName;
- Panel3.Caption := 'NG Real Name:';
- if GSubscribed then
- Edit3.Text := 'Subscribed' else Edit3.Text := 'UnSubscribed';
- Panel5.Caption := 'Status:';
- end;
- end;
- if newsgroupListloaded then exit;
- WorkingFileName := NewsPath + '\NEWSGRP.TXT';
- if FileExists( WorkingFileName ) then
- begin
- if MessageDlg( 'Load News Groups File? (Long operation...)',
- mtConfirmation,mbYesNoCancel,0) = mrYes then
- begin
- CCICInfoDlg.ListBox1.Clear;
- TheWorkingSL := TStringList.Create;
- try
- TheWorkingSL.LoadFromFile( WorkingFileName );
- CCICInfoDlg.ListBox1.Items.Assign( TheWorkingSL );
- except
- MessageDlg( 'News Group List Too Large! Use WordPad/Write to view ' +
- NewsPath + '\NEWGRP.TXT' , mtInformation,[mbOK],0);
- TheWorkingSL.Free;
- NewsgroupListLoaded := false;
- exit;
- end;
- TheWorkingSL.Free;
- NewsgroupListLoaded := true;
- end;
- end;
- end;
-
- { This procedure scans a line of UNIX-style text for #10's and }
- { outputs them as lines to the memo. It stops at #0. }
- procedure TCCINetCCForm.AddNullTermTextToMemo( TheTextToAdd : String;
- TheMemoToAddTo : TMemo );
- var
- TextLength , { Total chars to output }
- Counter_1 : integer; { Loop Index }
- begin
- { Make the target memo visible just in case }
- TheMemoToAddTo.Visible := true;
- { Find total chars to output }
- TextLength := Length( TheTextToAdd );
- { If none then leave }
- if TextLength = 0 then exit;
- { Loop along the string }
- for Counter_1 := 1 to TextLength do
- begin
- { If hit ASCII 10 then assume end of line and output }
- if TheTextToAdd[ Counter_1 ] = #10 then
- begin
- { Use a try loop incase memo fills up }
- try
- { Add the line }
- TheMemoToAddTo.Lines.Add( TheLine );
- except
- { If memo fills up }
- on EOutOfResources do
- begin
- { Clear the old data }
- TheMemoToAddTo.Clear;
- { Output the new }
- TheMemoToAddTo.Lines.Add( TheLine );
- end;
- end;
- { clear the output buffer }
- TheLine := '';
- end
- else
- { Otherwise look for null terminator from Winsock }
- begin
- { If don't hit null terminator then add the char to op buffer }
- if TheTextToAdd[ Counter_1 ] <> #0 then
- begin
- TheLine := TheLine + TheTextToAdd[ Counter_1 ];
- end
- else break; { Otherwise drop out of the loop }
- end;
- end;
- end;
-
- { This function scans a line of UNIX-style text for #10's and }
- { outputs the first line as its return value,stopping at #0. }
- function TCCINetCCForm.AddNullTermTextToLabel( TheTextToAdd : String ) : String;
- var
- TheLine : String; { Buffer to output current line }
- TextLength , { Total chars to output }
- Counter_1 : integer; { Loop Index }
- begin
- { Clear output buffer }
- TheLine := '';
- { Find total chars to output }
- TextLength := Length( TheTextToAdd );
- { If none then leave }
- if TextLength = 0 then
- begin
- { Return nothing }
- Result := '';
- { Leave }
- exit;
- end;
- { Loop along the string }
- for Counter_1 := 1 to TextLength do
- begin
- { If hit ASCII 10 then assume end of line and output }
- if TheTextToAdd[ Counter_1 ] = #10 then
- begin
- { Return first line }
- Result := TheLine;
- { Leave }
- exit;
- end
- else
- { Otherwise look for null terminator from Winsock }
- begin
- { If don't hit null terminator then add the char to op buffer }
- if TheTextToAdd[ Counter_1 ] <> #0 then
- begin
- TheLine := TheLine + TheTextToAdd[ Counter_1 ];
- end
- else break; { Otherwise drop out of the loop }
- end;
- end;
- { If hit #0 before #10 return buffer }
- Result := TheLine;
- end;
-
- { Show busy cursors }
- procedure TCCINetCCForm.SetHGCursors;
- begin
- CCInetCCForm.Cursor := crHourGlass;
- CCInetCCForm.Memo1.Cursor := crHourGlass;
- end;
-
- { Show normal cursors }
- procedure TCCINetCCForm.SetNormalCursors;
- begin
- CCInetCCForm.Cursor := crDefault;
- CCInetCCForm.Memo1.Cursor := crDefault;
- end;
-
- { Exit method }
- procedure TCCINetCCForm.Exit1Click(Sender: TObject);
- begin
- Close;
- end;
-
- { This method adds a line to the progress text stringlist }
- { If an exception occurs, the list is full, and it is auto }
- { saved to the progress text file name, then cleared. }
- procedure TCCINetCCForm.AddProgressText( WhatText : String );
- begin
- { Use a try..except loop to catch list overflows }
- try
- { Try the normal add }
- ProgressList.Add( WhatText );
- except
- { Any list error is assumed to be a list overflow }
- on EListError do
- begin
- { Save the list to the preset file name }
- ProgressList.SaveToFile( ProgressFileName );
- { Clear the list to make more room }
- ProgressList.Clear;
- { And redo the add; any further errors will except normally }
- ProgressList.Add( WhatText );
- end;
- { This might happen too! }
- on EOutOfResources do
- begin
- { Save the list to the preset file name }
- ProgressList.SaveToFile( ProgressFileName );
- { Clear the list to make more room }
- ProgressList.Clear;
- { And redo the add; any further errors will except normally }
- ProgressList.Add( WhatText );
- end;
- end;
- end;
-
- { This method either adds the progress line to the current memo }
- { or puts it in the status caption at normal colors. }
- procedure TCCINetCCForm.ShowProgressText( WhatText : String );
- begin
- { Use the POV to determine where to show progress info }
- case ProgressOutputVector of
- POV_MEMO : begin { Output into the memo }
- AddNullTermTextToMemo( WhatText , Memo1 );
- end;
- POV_STAT : begin { Output on status line }
- { Set panel caption font to black }
- Panel1.Font.Color := clBlack;
- { Get the first line of text and put in caption }
- Panel1.Caption := AddNullTermTextToLabel( WhatText );
- end;
- end;
- end;
-
- { This method is identical with SPT except sets status color to red and beeps }
- procedure TCCINetCCForm.ShowProgressErrorText( WhatText : String );
- begin
- { Do error beep }
- MessageBeep( mb_IconExclamation );
- { Use the POV to determine where to show progress info }
- case ProgressOutputVector of
- POV_MEMO : begin { Output into the memo }
- AddNullTermTextToMemo( WhatText , Memo1 );
- end;
- POV_STAT : begin { Output on status line }
- { Set panel caption font to black }
- Panel1.Font.Color := clRed;
- { Get the first line of text and put in caption }
- Panel1.Caption := AddNullTermTextToLabel( WhatText );
- end;
- end;
- end;
-
- { This is the boilerplate method used to handle Socket errors gracefully }
- procedure TCCINetCCForm.SocketsErrorOccurred( Sender : TObject;
- ErrorCode : Integer;
- TheMessage : String );
- begin
- { Set the global error code flag }
- GlobalErrorCode := ErrorCode;
- { If a timeout error }
- if ErrorCode = WSAETIMEDOUT then
- begin
- { Set the aborted flag }
- GlobalAbortedFlag := True;
- { But clear the error code for graceful handling }
- GlobalErrorCode := 0;
- end
- else
- begin
- { Otherwise set the progress buffer to the error message }
- AddProgressText( TheMessage );
- { And show the progress text as set by option }
- ShowProgressErrorText( TheMessage );
- end;
- end;
-
- procedure TCCINetCCForm.FormCreate(Sender: TObject);
- begin
- { Create the progress string list }
- ProgressList := TStringList.Create;
- { Create the file name for saving the progress list }
- ProgressFileName := ExpandFileName( 'PROGRESS.TXT' );
- { Default progress output to status line }
- ProgressOutputVector := POV_STAT;
- { Set password control stuff }
- PasswordControlVector := 2;
- CurrentPasswordString := 'guest@nowhere.com';
- CurrentRealPWString := 'guest@nowhere.com';
- NewMessageInProgress := false;
- EmailLoaded := false;
- NewsGroupListLoaded := false;
- { Get Ini file Data }
- ReadIniData;
- LoadFTPSiteFile;
- LoadNNTPSiteFile;
- LoadEMailServerFile;
- TheFTPComponent := TFTPComponent.Create( CCInetCCForm );
- TheFTPComponent.Parent := CCInetCCForm;
- TheNNTPComponent := TNNTPComponent.Create( CCInetCCForm );
- TheNNTPComponent.Parent := CCInetCCForm;
- ThePOP3SMTPComponent := TPOP3SMTPComponent.Create( CCInetCCForm );
- ThePOP3SMTPComponent.Parent := CCInetCCForm;
- TheUUObject := TUUCodingObject.Create( Self );
- TheUUObject.Parent := self;
- TheMIMEObject := TMIMECodingObject.Create( Self );
- TheMIMEObject.Parent := self;
- end;
-
- procedure TCCINetCCForm.FormDestroy(Sender: TObject);
- begin
- { Free the progress text stringlist if assigned }
- if assigned( ProgressList ) then ProgressList.Free;
- { Save off the Ini data }
- WriteIniData;
- { Save and remove FTP site list stuff }
- SaveFTPSiteFile;
- SaveNNTPSiteFile;
- SaveEmailServerFile;
- if Assigned( TheFTPComponent ) then TheFTPComponent.Free;
- if Assigned( TheNNTPComponent ) then TheNNTPComponent.Free;
- if Assigned( ThePOP3SMTPComponent ) then ThePOP3SMTPComponent.Free;
- if Assigned( TheUUObject ) then TheUUObject.Free;
- if Assigned( TheMIMEObject ) then TheMIMEObject.Free;
- end;
-
- procedure TCCINetCCForm.Description1Click(Sender: TObject);
- var
- TempSocket : TCCSocket; { Temporary socket just to get Winsock info }
- TheData : String; { Holder for data }
- begin
- { Create socket; auto calls WSAStartup }
- TempSocket := TCCSocket.Create( Self );
- { Do parent just for kicks; no longer needed }
- TempSocket.Parent := self;
- { Put in error handler }
- TempSocket.OnErrorOccurred := SocketsErrorOccurred;
- TheData := StrPas( TempSocket.Socket_WSA_Data.Description_String );
- { Display the Description String }
- AddProgressText( TheData );
- { And show the progress text as set by option }
- ShowProgressText( TheData );
- { Free the socket; auto calls WSACleanup }
- TempSocket.Free;
- end;
-
- procedure TCCINetCCForm.SystemStatus1Click(Sender: TObject);
- var
- TempSocket : TCCSocket; { Temporary socket just to get Winsock info }
- TheData : String; { Holder for data }
- begin
- { Create socket; auto calls WSAStartup }
- TempSocket := TCCSocket.Create( Self );
- { Do parent just for kicks; no longer needed }
- TempSocket.Parent := self;
- { Put in error handler }
- TempSocket.OnErrorOccurred := SocketsErrorOccurred;
- TheData := StrPas( TempSocket.Socket_WSA_Data.System_Status_String );
- { Display the Description String }
- AddProgressText( TheData );
- { And show the progress text as set by option }
- ShowProgressText( TheData );
- { Free the socket; auto calls WSACleanup }
- TempSocket.Free;
- end;
-
- procedure TCCINetCCForm.VendorSpecific1Click(Sender: TObject);
- var
- TempSocket : TCCSocket; { Temporary socket just to get Winsock info }
- TheData : String; { Holder for data }
- begin
- { Create socket; auto calls WSAStartup }
- TempSocket := TCCSocket.Create( Self );
- { Do parent just for kicks; no longer needed }
- TempSocket.Parent := self;
- { Put in error handler }
- TempSocket.OnErrorOccurred := SocketsErrorOccurred;
- TheData := StrPas( TempSocket.Socket_WSA_Data.Vendor_Specific_String );
- { Display the Description String }
- AddProgressText( TheData );
- { And show the progress text as set by option }
- ShowProgressText( TheData );
- { Free the socket; auto calls WSACleanup }
- TempSocket.Free;
- end;
-
- { This method sets the progress output vector to the memo }
- procedure TCCINetCCForm.ViewInEditWindow1Click(Sender: TObject);
- begin
- { Set the vector }
- ProgressOutputVector := POV_MEMO;
- { Keep the menu options consistent }
- ViewInEditWindow1.Checked := true;
- ViewInStatusLine1.Checked := false;
- end;
-
- { This method sets the progress output vector to the status line }
- procedure TCCINetCCForm.ViewInStatusLine1Click(Sender: TObject);
- begin
- { Set the vector }
- ProgressOutputVector := POV_STAT;
- { Keep the menus consistent }
- ViewInEditWindow1.Checked := false;
- ViewInStatusLine1.Checked := true;
- end;
-
- procedure TCCINetCCForm.SaveToFile1Click(Sender: TObject);
- begin
- { Set up the dialog parameters }
- OpenDialog1.Filename := ProgressFileName;
- OpenDialog1.Title := 'Select Filename for Progress File';
- OpenDialog1.Filter := 'Text Files|*.txt';
- { If the dialog is not cancelled then save and clear }
- if OpenDialog1.Execute then
- begin
- ProgressFileName := OpenDialog1.FileName;
- ProgressList.SaveToFile( ProgressFileName );
- ProgressList.Clear;
- end;
- end;
-
- procedure TCCINetCCForm.IPAddress1Click(Sender: TObject);
- begin
- { Set up info dialog for IP Address getting }
- CCICInfoDlg.Caption := 'CC Internet Center -- Translate IP Address';
- CCICInfoDlg.Panel4.Visible := false;
- CCICInfoDlg.Panel6.Visible := false;
- CCICInfoDlg.Panel9.Visible := false;
- CCICInfoDlg.Panel8.Visible := false;
- CCICInfoDlg.BitBtn2.Visible := false;
- CCICInfoDlg.Button1.Caption := 'Get IP Address';
- CCICInfoDlg.Button2.Visible := false;
- CCICInfoDlg.Button3.Visible := false;
- CCICInfoDlg.Button4.Visible := false;
- CCICInfoDlg.Panel2.Caption := 'IP Addr Name:';
- CCICInfoDlg.Panel3.Caption := ' Dotted Dec:';
- CCICInfoDlg.Panel5.Caption := ' Binary:';
- CCICInfoDlg.Edit1.Text := '';
- CCICInfoDlg.Edit2.Text := '';
- CCICInfoDlg.Edit3.Text := '';
- { Set IP Address Mode }
- CCICInfoDlg.Tag := 1;
- { Show Modally to get the information }
- CCICInfoDlg.ShowModal;
- { Reset the info dialog to default conditions }
- CCICInfoDlg.Caption := 'CC Internet Command Center Information Dialog';
- CCICInfoDlg.Panel4.Visible := true;
- CCICInfoDlg.Panel6.Visible := true;
- CCICInfoDlg.Panel9.Visible := true;
- CCICInfoDlg.Panel8.Visible := true;
- CCICInfoDlg.BitBtn2.Visible := true;
- CCICInfoDlg.Button1.Caption := 'Anonymous Login';
- CCICInfoDlg.Button2.Visible := true;
- CCICInfoDlg.Button3.Visible := true;
- CCICInfoDlg.Button4.Visible := true;
- CCICInfoDlg.Panel2.Caption := ' Name:';
- CCICInfoDlg.Panel3.Caption := ' IP Address:';
- CCICInfoDlg.Panel5.Caption := ' User Name:';
- CCICInfoDlg.Edit1.Text := '';
- CCICInfoDlg.Edit2.Text := '';
- CCICInfoDlg.Edit3.Text := '';
- end;
-
- procedure TCCINetCCForm.FTP1Click(Sender: TObject);
- begin
- { Set up the FTP Data displays }
- SetupFTPSiteLists;
- ListBox1.Clear;
- ListBox2.Clear;
- end;
-
- procedure TCCINetCCForm.FormResize(Sender: TObject);
- begin
- { Use tag vector to determine what to do }
- case Tag of
- { if FTP , make sure two list boxes are same height }
- 2 : begin
- Panel6.Height := (( Panel4.Height div 2 ) - 30 );
- Panel4.Width := 185;
- end;
- 4 : begin
- Panel6.Height := 118;
- Panel4.Width := 250;
- end;
- end;
- end;
-
- procedure TCCINetCCForm.FTPSites1Click(Sender: TObject);
- begin
- { Show Modally to get the information }
- CCICInfoDlg.ShowModal;
- end;
-
- procedure TCCINetCCForm.FTP3Click(Sender: TObject);
- begin
- CCICPrefsDlg.TabbedNoteBook1.PageIndex := 1;
- CCICPrefsDlg.Tag := 2;
- CCICPrefsDlg.ShowModal;
- end;
-
- procedure TCCINetCCForm.ConnectToSite1Click(Sender: TObject);
- var Counter_1 : Integer;
- begin
- if Lowercase( PConnectionsRecord( TheFTPSiteList.Items[
- ComboBox1.ItemIndex ] )^.CUserName ) = 'anonymous' then
- begin
- for Counter_1 := 1 to TheAnonRedialVector do
- begin
- DoFTPConnection( PConnectionsRecord(
- TheFTPSiteList.Items[ ComboBox1.ItemIndex ] ));
- if TheFTPComponent.Connection_Established then exit;
- end;
- end
- else DoFTPConnection( PConnectionsRecord(
- TheFTPSiteList.Items[ ComboBox1.ItemIndex ] ));
- end;
-
- procedure TCCINetCCForm.Button1Click(Sender: TObject);
- begin
- case Tag of
- 2 : begin
- if not TheFTPComponent.Connection_Established then
- ConnectToSite1Click( Self ) else
- begin
- DoFTPDisconnect;
- TheFTPComponent.Connection_Established := false;
- DisableFTPMenus;
- end;
- end;
- 4 : begin
- ConnectAndUpdate1Click( Self );
- end;
- 5 : begin
- GetMarked1Click( Self );
- end;
- 6 : begin
- CheckMail1Click( Self );
- end;
- end;
- end;
-
- procedure TCCINetCCForm.ViewasText1Click(Sender: TObject);
- begin
- { Assume valid FTP component and have it send its text into the progress text}
- TheFTPComponent.GetRemoteDirectoryListingToMemo;
- end;
-
- procedure TCCINetCCForm.Disconnect1Click(Sender: TObject);
- begin
- DoFTPDisconnect;
- DisableFTPMenus;
- end;
-
- procedure TCCINetCCForm.EnableFTPMenus;
- begin
- Button1.Caption := 'Disconnect';
- ConnectToSite1.Enabled := false;
- Disconnect1.Enabled := true;
- Directory1.Enabled := true;
- UploadMarked1.Enabled := true;
- DownloadMarked1.Enabled := true;
- end;
-
- procedure TCCINetCCForm.DisableFTPMenus;
- begin
- Button1.Caption := 'Connect';
- ConnectToSite1.Enabled := true;
- Disconnect1.Enabled := false;
- Directory1.Enabled := false;
- UploadMarked1.Enabled := false;
- DownloadMarked1.Enabled := false;
- FTP1.Enabled := true;
- UseNetNws1.Enabled := true;
- IPAddress1.Enabled := true;
- FTP2.Enabled := false;
- end;
-
- procedure TCCINetCCForm.EnableNNTPMenus;
- begin
- Button1.Caption := 'Disconnect';
- ConnectAndUpdate1.Enabled := false;
- Disconnect2.Enabled := true;
- CheckNewNews1.Enabled := true;
- GetMarked1.Enabled := true;
- Article1.Enabled := true;
- Post1.Enabled := true;
- SubScribedNewsgroups1.Enabled := true;
- Trash1.Enabled := true;
- Headers1.Enabled := true;
- DownLoadActiveNewsGroups1.Enabled := true;
- end;
-
- procedure TCCINetCCForm.DisableNNTPMenus;
- begin
- Button1.Caption := 'Connect';
- ConnectAndUpdate1.Enabled := True;
- Disconnect2.Enabled := false;
- CheckNewNews1.Enabled := false;
- GetMarked1.Enabled := false;
- Article1.Enabled := false;
- Post1.Enabled := false;
- SubScribedNewsgroups1.Enabled := false;
- Trash1.Enabled := false;
- Headers1.Enabled := false;
- DownLoadActiveNewsGroups1.Enabled := false;
- end;
-
- procedure TCCINetCCForm.ToDisplay1Click(Sender: TObject);
- var Counter_1 : Integer;
- begin
- for Counter_1 := 0 to Listbox1.Items.Count - 1 do
- begin
- if Listbox1.Selected[ Counter_1 ] then
- begin
- FileNameToXFer := ListBox1.Items[ Counter_1 ];
- TheFTPComponent.
- ReceiveASCIIRemoteFileToMemo( Listbox1.Items[ Counter_1 ] );
- end;
- end;
- end;
-
- procedure TCCINetCCForm.ToFile1Click(Sender: TObject);
- var Counter_1 : Integer;
- W16Name : String;
- begin
- for Counter_1 := 0 to Listbox1.Items.Count - 1 do
- begin
- if Listbox1.Selected[ Counter_1 ] then
- begin
- FileNameToXFer := ListBox1.Items[ Counter_1 ];
- W16Name := TheFTPComponent.GetWin16Filename( FileNameToXFer );
- TheFTPComponent.
- ReceiveASCIIRemoteFile( Listbox1.Items[ Counter_1 ] , W16Name );
- end;
- end;
- end;
-
- procedure TCCINetCCForm.Binary2Click(Sender: TObject);
- var Counter_1 : Integer;
- W16Name : String;
- begin
- for Counter_1 := 0 to Listbox1.Items.Count - 1 do
- begin
- if Listbox1.Selected[ Counter_1 ] then
- begin
- FileNameToXFer := ListBox1.Items[ Counter_1 ];
- W16Name := TheFTPComponent.GetWin16Filename( FileNameToXFer );
- TheFTPComponent.
- ReceiveBinaryRemoteFile( Listbox1.Items[ Counter_1 ] , W16Name );
- end;
- end;
- end;
-
- procedure TCCINetCCForm.Change1Click(Sender: TObject);
- var TheDir : String;
- begin
- if ListBox1.ItemIndex = -1 then exit;
- TheDir := ListBox1.Items[ ListBox1.ItemIndex ];
- if TheFTPComponent.SetRemoteDirectory( TheDir ) then
- begin
- TheFTPComponent.GetRemoteWorkingDirectory( TheDir );
- { Put up remote directory via PWD and strip quotes }
- Label4.Caption := TheFTPComponent.GetQuotedString( TheDir );
- { Get the listings of directories and exit OK }
- TheFTPComponent.GetRemoteDirectoryListing( Listbox1 );
- end;
- end;
-
- procedure TCCINetCCForm.ChangeLocal1Click(Sender: TObject);
- var TheDir : String;
- begin
- if ListBox2.ItemIndex = -1 then exit;
- TheDir := ListBox2.Items[ ListBox2.ItemIndex ];
- TheDir := TheFTPComponent.StripBrackets( TheDir );
- if TheDir = '..' then
- begin
- ChDir( TheDir );
- end
- else
- begin
- TheDir := ExpandFileName( TheDir );
- ChDir( TheDir );
- end;
- TheFTPComponent.GetLocalDirectoryAndListing( TheDir , Listbox2 );
- if Label5.Canvas.TextWidth( TheDir ) > Label5.Width then
- TheDir := TheFTPComponent.GetShortPathName( TheDir );
- Label5.Caption := TheDir;
- end;
-
- procedure TCCINetCCForm.ListBox1DblClick(Sender: TObject);
- begin
- case Tag of
- 2 : begin
- case DefaultDownLoadVector of
- 1 : Binary2Click( Self );
- 2 : ToFile1Click( Self );
- 3 : Change1Click( Self );
- end;
- end;
- end;
- end;
-
- procedure TCCINetCCForm.ListBox2DblClick(Sender: TObject);
- var WorkingString ,
- NumberString : String;
- TheIDNumber : Integer;
- TheNGARecord : PNewsGroupArticleRecord;
- begin
- case Tag of
- 2 : begin
- case DefaultDownLoadVector of
- 1 : Binary1Click( Self );
- 2 : ASCII1Click( Self );
- 3 : ChangeLocal1Click( Self );
- end;
- end;
- 5 : begin
- if ListBox2.Tag <> 5 then exit;
- if ListBox2.ItemIndex = -1 then exit;
- WorkingString := ListBox2.Items[ ListBox2.ItemIndex ];
- NumberString := TheFTPComponent.StripBrackets( WorkingString );
- TheIDNumber := StrToInt( NumberString );
- TheNGARecord := PNewsGroupArticleRecord(
- TheNGArticlesList.Items[ TheIDNumber ] );
- if TheNGARecord^.NGADownloaded then
- begin
- Memo1.Clear;
- try
- Memo1.Lines.LoadFromFile( NewsPath + '\' + TheNGARecord^.NGAArtFileName );
- except
- MessageDlg( 'Article Too Large to Load! Use Write to View [' +
- TheNGARecord^.NGAArtFilename + '.',
- mtError,[mbOK],0);
- exit;
- end;
- Label1.Caption := 'Subject:';
- ComboBox1.Text := TheNGARecord^.NGASubject;
- TheNGARecord^.NGARead := true;
- WorkingString := ListBox2.Items[ ListBox2.ItemIndex ];
- WorkingString[ 3 ] := 'R';
- ListBox2.Items[ ListBox2.ItemIndex ] := WorkingString;
- end
- else
- begin
- MessageDlg( 'Article Not Downloaded!',mtError,[mbOK],0);
- end;
- end;
- 6 : begin
- if ListBox2.ItemIndex = -1 then exit;
- WorkingString := PEMailMessageRecord(
- TheMBMessagesList.Items[ ListBox2.ItemIndex ] )^.MRFileName;
- PEMailMessageRecord(
- TheMBMessagesList.Items[ ListBox2.ItemIndex ] )^.MRRead := true;;
- WorkingString := MailPath + '\' + WorkingString;
- Memo1.Clear;
- try
- Memo1.Lines.LoadFromFile( WorkingString );
- except
- MessageDlg( 'Article Too Large to Load! Use Write to View.',
- mtError,[mbOK],0);
- exit;
- end;
- Label1.Caption := 'Subject:';
- ComboBox1.Text := PEMailMessageRecord(
- TheMBMessagesList.Items[ ListBox2.ItemIndex ] )^.MRMessageSubject;
- PopulateLB2WithMessageHeaders;
- end;
- end;
- end;
-
- procedure TCCINetCCForm.ASCII1Click(Sender: TObject);
- var Counter_1 : Integer;
- TheDir : String;
- begin
- for Counter_1 := 0 to Listbox2.Items.Count - 1 do
- begin
- if Listbox2.Selected[ Counter_1 ] then
- begin
- FileNameToXFer := ListBox2.Items[ Counter_1 ];
- TheFTPComponent.
- SendASCIILocalFile( Listbox2.Items[ Counter_1 ] );
- end;
- end;
- TheFTPComponent.GetRemoteWorkingDirectory( TheDir );
- { Put up remote directory via PWD and strip quotes }
- Label4.Caption := TheFTPComponent.GetQuotedString( TheDir );
- { Get the listings of directories and exit OK }
- TheFTPComponent.GetRemoteDirectoryListing( Listbox1 );
- end;
-
- procedure TCCINetCCForm.DeleteRemoteFiles1Click(Sender: TObject);
- var Counter_1 : Integer;
- TheDir : String;
- DoAll : Boolean;
- TheResult : Integer;
- begin
- DoAll := false;
- for Counter_1 := 0 to Listbox1.Items.Count - 1 do
- begin
- if Listbox1.Selected[ Counter_1 ] then
- begin
- if not DoAll then
- begin
- TheResult := MessageDlg( 'Delete Remote File ' +
- ListBox1.Items[ Counter_1 ] + ' ?',mtConfirmation,
- [mbYes,mbNo,mbCancel,mbAll],0 );
- case TheResult of
- mrYes : ;
- mrNo : ;
- mrCancel : break;
- mrAll : begin
- TheResult := mrYes;
- DoAll := true;
- end;
- end;
- end
- else TheResult := mrYes;
- if TheResult = mrYes then TheFTPComponent.
- DeleteRemoteFile( Listbox1.Items[ Counter_1 ] );
- end;
- end;
- TheFTPComponent.GetRemoteWorkingDirectory( TheDir );
- { Put up remote directory via PWD and strip quotes }
- Label4.Caption := TheFTPComponent.GetQuotedString( TheDir );
- { Get the listings of directories and exit OK }
- TheFTPComponent.GetRemoteDirectoryListing( Listbox1 );
- end;
-
- procedure TCCINetCCForm.Binary1Click(Sender: TObject);
- var Counter_1 : Integer;
- TheDir : String;
- begin
- for Counter_1 := 0 to Listbox2.Items.Count - 1 do
- begin
- if Listbox2.Selected[ Counter_1 ] then
- begin
- FileNameToXFer := ListBox2.Items[ Counter_1 ];
- TheFTPComponent.
- SendBinaryLocalFile( Listbox2.Items[ Counter_1 ] );
- end;
- end;
- TheFTPComponent.GetRemoteWorkingDirectory( TheDir );
- { Put up remote directory via PWD and strip quotes }
- Label4.Caption := TheFTPComponent.GetQuotedString( TheDir );
- { Get the listings of directories and exit OK }
- TheFTPComponent.GetRemoteDirectoryListing( Listbox1 );
- end;
-
- procedure TCCINetCCForm.Delete3Click(Sender: TObject);
- var Counter_1 : Integer;
- TheDir : String;
- begin
- for Counter_1 := 0 to Listbox1.Items.Count - 1 do
- begin
- if Listbox1.Selected[ Counter_1 ] then
- begin
- if ListBox1.Items[ Counter_1 ] <> '..' then
- TheFTPComponent.
- DeleteRemoteDirectory( Listbox1.Items[ Counter_1 ] );
- end;
- end;
- TheFTPComponent.GetRemoteWorkingDirectory( TheDir );
- { Put up remote directory via PWD and strip quotes }
- Label4.Caption := TheFTPComponent.GetQuotedString( TheDir );
- { Get the listings of directories and exit OK }
- TheFTPComponent.GetRemoteDirectoryListing( Listbox1 );
- end;
-
- procedure TCCINetCCForm.Create1Click(Sender: TObject);
- var TheDir : String;
- begin
- OpenDialog1.Filename := '*.*';
- OpenDialog1.Title := 'Enter Remote Directory Name';
- if OpenDialog1.Execute then
- begin
- TheFTPComponent.
- CreateRemoteDirectory( ExtractFileName( OpenDialog1.FileName ));
- TheFTPComponent.GetRemoteWorkingDirectory( TheDir );
- { Put up remote directory via PWD and strip quotes }
- Label4.Caption := TheFTPComponent.GetQuotedString( TheDir );
- { Get the listings of directories and exit OK }
- TheFTPComponent.GetRemoteDirectoryListing( Listbox1 );
- end;
- end;
-
- procedure TCCINetCCForm.ListBox1Click(Sender: TObject);
- var TheNGRecord : PNewsGroupRecord;
- TheMBRecord : PEMailMailboxRecord;
- begin
- case ListBox1.Tag of
- 5 : begin
- if ListBox1.ItemIndex = -1 then exit;
- TheNGRecord :=
- PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- TheNGArticlesList := TList( TheNGRecord^.GLTag );
- PopulateLB2WithArticleHeaders;
- ComboBox1.ItemIndex := ListBox1.ItemIndex;
- end;
- 6 : begin
- if ListBox1.ItemIndex = -1 then exit;
- TheMBRecord :=
- PEMailMailboxRecord( TheEMailMailboxList.Items[ ListBox1.ItemIndex ] );
- TheMBMessagesList := TList( TheMBRecord^.MBLTag );
- PopulateLB2WithMessageHeaders;
- end;
- end;
- end;
-
- procedure TCCINetCCForm.UsenetNws1Click(Sender: TObject);
- begin
- if TheFTPComponent.Connection_Established then
- begin
- MessageDlg( 'Must disconnect from current FTP session first!',
- mtError,[mbOK],0);
- exit;
- end;
- { Show The NNTP servers display }
- ListBox1.Clear;
- ListBox2.Clear;
- SetupNNTPSiteLists;
- NewsGroupListLoaded := false;
- SetupNNTPServersInfoDisplay;
- end;
-
- procedure TCCINetCCForm.Disconnect2Click(Sender: TObject);
- begin
- SaveNNTPNewsGroupLists;
- DoNNTPDisconnect;
- DisableNNTPMenus;
- ListBox1.Clear;
- ListBox2.Clear;
- end;
-
- procedure TCCINetCCForm.News2Click(Sender: TObject);
- begin
- CCICPrefsDlg.TabbedNoteBook1.PageIndex := 2;
- CCICPrefsDlg.Tag := 4;
- CCICPrefsDlg.ShowModal;
- end;
-
- procedure TCCINetCCForm.ConnectandUpdate1Click(Sender: TObject);
- begin
- DoNNTPConnection( PConnectionsRecord(
- TheNewsServerList.Items[ ComboBox1.ItemIndex ] ));
- if TheNNTPComponent.Connection_Established then
- begin
- SetupNNTPNewsGroupLists;
- if NewsInitialUpdateVector = 1 then
- begin { Update all active newsgroups }
- TheNNTPComponent.CheckAllNewNews;
- end;
- { Bring up the files with current NG information }
- SetupNewsGroupListboxes;
- end;
- end;
-
- procedure TCCINetCCForm.CheckNewNews1Click(Sender: TObject);
- begin
- TheNNTPComponent.CheckAllNewNews;
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.NewsServers1Click(Sender: TObject);
- begin
- { Reset display to NNTP Servers }
- SetupNNTPServersInfoDisplay;
- { Show Modally to get the information }
- CCICInfoDlg.ShowModal;
- end;
-
- procedure TCCINetCCForm.SubscribedNewsgroups1Click(Sender: TObject);
- begin
- { Reset display to Usenet Newsgroups }
- SetupNNTPNewsGroupsInfoDisplay;
- { Show Modally to get the information }
- CCICInfoDlg.ShowModal;
- TheNNTPComponent.CheckAllNewNews;
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.RetrieveMarked1Click(Sender: TObject);
- var Counter_1 : Integer;
- TheNGRecord : PNewsGroupRecord;
- begin
- for Counter_1 := 0 to ListBox1.Items.Count - 1 do
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] );
- if (( TheNGRecord^.GSubscribed ) and ( ListBox1.Selected[ Counter_1 ] )) then
- begin
- TheNNTPComponent.GetAllArticleHeaders( TheNGRecord );
- end;
- end;
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.RetrieveAll1Click(Sender: TObject);
- var Counter_1 : Integer;
- TheNGRecord : PNewsGroupRecord;
- begin
- for Counter_1 := 0 to TheNewsRCList.Count - 1 do
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] );
- if TheNGRecord^.GSubscribed then
- begin
- TheNNTPComponent.GetAllArticleHeaders( TheNGRecord );
- end;
- end;
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.GetMarked1Click(Sender: TObject);
- var TheNGRecord : PNewsGroupRecord;
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- TheNNTPComponent.DownloadAllMarkedArticleListings( TheNGRecord , ListBox2 );
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.NewArticle1Click(Sender: TObject);
- begin
- if ListBox1.ItemIndex = -1 then exit;
- Memo1.Clear;
- TheNNTPComponent.SetNewsHeaders( Memo1 , ListBox1.ItemIndex );
- end;
-
- procedure TCCINetCCForm.FollowupArticle1Click(Sender: TObject);
- begin
- if ListBox1.ItemIndex = -1 then exit;
- if ListBox2.ItemIndex = -1 then exit;
- Memo1.Clear;
- TheNNTPComponent.SetFUNewsHeaders( Memo1 ,
- ListBox1.ItemIndex ,
- ListBox2.ItemIndex );
- end;
-
- procedure TCCINetCCForm.PutinQueue1Click(Sender: TObject);
- var TheNGRecord : PNewsGroupRecord;
- TheNGARecord : PNewsGroupArticleRecord;
- WorkingList : TList;
- WorkingFilename : String;
- Holdingposition : Integer;
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- WorkingList := TList( TheNGRecord^.GLTag );
- New( TheNGARecord );
- with TheNGARecord^ do
- begin
- NGAGroupname := TheNGRecord^.GRealName;
- NGASubject := TheNNTPComponent.GetHeaderSubject( TStringList( Memo1.Lines ));
- NGANumber := TheNGRecord^.GHighestAvailable + WorkingList.Count;
- NGADownloaded := true;
- NGASender := 'CIUPKC158';
- NGARead := false;
- NGAPosted := false;
- WorkingFileName := 'AR' + IntToStr( NGANumber );
- if Length( WorkingFileName ) > 8 then
- WorkingFileName := Copy( WorkingFileName ,1 , 8 );
- WorkingFileName := WorkingFileName + '.' + IntToStr( TheNGRecord^.GIDNumber );
- NGAArtFileName := WorkingFileName;
- end;
- WorkingList.Add( TheNGARecord );
- Memo1.Lines.SaveToFile( NewsPath + '\' + WorkingFileName );
- HoldingPosition := ListBox1.itemindex;
- SetupNewsGroupListboxes;
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ HoldingPosition ] );
- TheNGArticlesList := TList( TheNGRecord^.GLTag );
- PopulateLB2WithArticleHeaders;
- end;
-
- procedure TCCINetCCForm.CurrentArticle1Click(Sender: TObject);
- var TheNGARecord : PNewsGroupArticleRecord;
- TheNGRecord : PNewsGroupRecord;
- HP : Integer;
- begin
- HP := ListBox1.itemindex;
- PutInQueue1Click( Self );
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ HP ] );
- TheNGArticlesList := TList( TheNGRecord^.GLTag );
- TheNGARecord := PNewsGroupArticleRecord( TheNGArticlesList.Items[ TheNGArticlesList.Count - 1 ] );
- TheNNTPComponent.UploadArticleListing( TheNGARecord );
- end;
-
- procedure TCCINetCCForm.EntireQueue1Click(Sender: TObject);
- var TheNGRecord : PNewsGroupRecord;
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- TheNNTPComponent.UploadAllArticleListings( TheNGRecord );
- end;
-
- procedure TCCINetCCForm.AllReadArticles1Click(Sender: TObject);
- var TheNGRecord : PNewsGroupRecord;
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- TheNNTPComponent.PurgeReadSentArticleListings( TheNGRecord );
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.AllMarkedArticles1Click(Sender: TObject);
- var TheNGRecord : PNewsGroupRecord;
- TheNGARecord : PNewsGroupArticleRecord;
- WorkingList : TList;
- Counter_1 : Integer;
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- WorkingList := TList( TheNGRecord^.GLTag );
- for Counter_1 := 0 to ListBox2.Items.Count - 1 do
- begin
- if ListBox2.Selected[ Counter_1 ] then
- begin
- TheNGARecord := PNewsGroupArticleRecord( WorkingList.Items[ Counter_1 ] );
- TheNGARecord^.NGARead := true;
- end;
- end;
- TheNNTPComponent.PurgeReadSentArticleListings( TheNGRecord );
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.AllAvailableArticles1Click(Sender: TObject);
- var TheNGRecord : PNewsGroupRecord;
- TheNGARecord : PNewsGroupArticleRecord;
- WorkingList : TList;
- Counter_1 : Integer;
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- WorkingList := TList( TheNGRecord^.GLTag );
- for Counter_1 := 0 to ListBox2.Items.Count - 1 do
- begin
- TheNGARecord := PNewsGroupArticleRecord( WorkingList.Items[ Counter_1 ] );
- TheNGARecord^.NGARead := true;
- end;
- TheNNTPComponent.PurgeReadSentArticleListings( TheNGRecord );
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.DownloadActiveNewsgroups1Click(Sender: TObject);
- begin
- if MessageDlg( 'This will take considerable time. Proceed?',mtConfirmation,
- mbYesNoCancel,0) = mrYes then
- begin
- Memo1.Clear;
- TheNNTPComponent.GetListofAvailableNewsGroups;
- end;
- end;
-
- procedure TCCINetCCForm.UUEncode1Click(Sender: TObject);
- begin
- OpenDialog1.Filename := '*.*';
- OpenDialog1.Title := 'Select File to UUENCODE';
- if OpenDialog1.Execute then
- begin
- TheUUObject.SetInputFileName( OpenDialog1.FileName );
- TheUUObject.EncodeCurrentInputs;
- end;
- end;
-
- procedure TCCINetCCForm.Load1Click(Sender: TObject);
- var Memo2 : TMemo;
- Counter_1 : Integer;
- begin
- OpenDialog1.Filename := '*.txt';
- OpenDialog1.Title := 'Select File to load into Memo';
- if OpenDialog1.Execute then
- begin
- Memo2 := TMemo.Create( Self );
- Memo2.Parent := Self;
- Memo2.Visible := false;
- Memo2.Width := Memo1.Width;
- Memo2.Height := Memo1.Height;
- Memo2.Lines.LoadFromFile( OpenDialog1.FileName );
- for Counter_1 := 0 to Memo2.Lines.Count - 1 do
- Memo1.Lines.Add( Memo2.Lines[ Counter_1 ] );
- Memo2.Free;
- end;
- end;
-
- procedure TCCINetCCForm.Save1Click(Sender: TObject);
- begin
- SaveDialog1.Filename := '*.txt';
- SaveDialog1.Title := 'Select File to Save Memo to';
- if OpenDialog1.Execute then
- begin
- Memo1.Lines.SaveToFile( SaveDialog1.FileName );
- end;
- end;
-
- procedure TCCINetCCForm.EMail1Click(Sender: TObject);
- begin
- if TheFTPComponent.Connection_Established then
- begin
- MessageDlg( 'Must disconnect from current FTP session first!',
- mtError,[mbOK],0);
- exit;
- end;
- if TheNNTPComponent.Connection_Established then
- begin
- MessageDlg( 'Must disconnect from current NNTP session first!',
- mtError,[mbOK],0);
- exit;
- end;
- { Show The POP3SMTP servers display }
- ListBox1.Clear;
- ListBox2.Clear;
- SetupEMailServerStatus;
- EnablePOP3SMTPMenus;
- SetupEMailServersInfoDisplay;
- end;
-
- procedure TCCINetCCForm.CheckMail1Click(Sender: TObject);
- begin
- WhichServer := ComboBox1.ItemIndex + 1;
- if not EMailLoaded then
- begin
- LoadEMailMailBoxFile( WhichServer );
- LoadEMailCorrespondentsFile;
- EmailLoaded := true;
- end;
- DoPOP3Connection( TheEMailServerList.Items[ WhichServer - 1 ] );
- ThePOP3SMTPComponent.DownloadAllMessageListings(
- PEMailMailBoxRecord( TheEMailMailboxList.Items[ 0 ] ));
- ThePOP3SMTPComponent.POP3Disconnect;
- SetupEMailListBoxes;
- end;
-
- procedure TCCINetCCForm.CreateNewMessage1Click(Sender: TObject);
- begin
- Label2.Visible := true;
- Label3.visible := true;
- ComboBox2.Visible := true;
- ComboBox3.visible := true;
- ThePOP3SMTPComponent.SetMailHeaders( Memo1 ,
- PConnectionsRecord( TheEMailServerList.Items[ WhichServer - 1 ] ));
- NewMessageInProgress := true;
- end;
-
- procedure TCCINetCCForm.ReplyToCurrentMessage1Click(Sender: TObject);
- begin
- Label2.Visible := true;
- Label3.visible := true;
- ComboBox2.Visible := true;
- ComboBox3.visible := true;
- ThePOP3SMTPComponent.SetReplyMailHeaders( Memo1 ,
- PConnectionsRecord( TheEMailServerList.Items[ WhichServer - 1 ] ) ,
- PEMailMailboxRecord( TheEMailMailboxList.Items[ ListBox1.ItemIndex ] ) ,
- ListBox2.ItemIndex );
- NewMessageInProgress := true;
- end;
-
- procedure TCCINetCCForm.SendCurrentMessage1Click(Sender: TObject);
- var TheEMMRecord : PEMailMessageRecord;
- WorkingNumber : Integer;
- WorkingFileName : String;
- WorkingList : TList;
- begin
- Label2.Visible := false;
- Label3.visible := false;
- ComboBox2.Visible := false;
- ComboBox3.visible := false;
- if not NewMessageInProgress then exit;
- NewMessageInProgress := false;
- New( TheEMMRecord );
- ThePOP3SMTPComponent.ExtractHeaderInfoFromMemo( Memo1 , TheEMMRecord );
- WorkingNumber := ListBox2.Items.Count + 1;
- with TheEMMRecord^ do
- begin
- MRSent := false;
- WorkingFileName := 'EM' + IntToStr( WorkingNumber );
- if Length( WorkingFileName ) > 8 then WorkingFileName :=
- Copy( WorkingFileName , 1 , 8 );
- WorkingFileName := WorkingFileName + '.2';
- MRFileName := WorkingFileName;
- WorkingFileName := MailPath + '\' + WorkingFileName;
- Memo1.Lines.SaveToFile( WorkingFileName );
- end;
- Inc( PEMailMailBoxRecord(
- TheEMailMailBoxList.Items[ 1 ] )^.MBTotal );
- Inc( PEMailMailBoxRecord(
- TheEMailMailBoxList.Items[ 1 ] )^.MBUnSentTotal );
- WorkingList := TList( PEMailMailBoxRecord(
- TheEMailMailBoxList.Items[ 1 ] )^.MBLTag );
- WorkingList.Add( TheEMMRecord );
- PEMailMailBoxRecord(
- TheEMailMailBoxList.Items[ 1 ] )^.MBLTag :=
- Longint( WorkingList );
- If EMQueueVector = 2 then
- begin
- DoSMTPConnection( TheEMailServerList.Items[ WhichServer - 1 ] );
- ThePOP3SMTPComponent.UploadMessageListing( TheEMMRecord );
- {ThePOP3SMTPComponent.SMTPDisconnect;}
- end;
- TheMBMessagesList := WorkingList;
- SetupEMailListBoxes;
- Memo1.Clear;
- end;
-
- procedure TCCINetCCForm.SendQueue1Click(Sender: TObject);
- var WorkingList : TList;
- begin
- SendCurrentMessage1Click( Self );
- Memo1.Clear;
- DoSMTPConnection( TheEMailServerList.Items[ WhichServer - 1 ] );
- ThePOP3SMTPComponent.UploadAllMessageListings( PConnectionsRecord(
- TheEMailServerList.Items[ WhichServer - 1 ] ),
- PEMailMailboxRecord( TheEMailMailboxList.Items[ 1 ] ));
- {ThePOP3SMTPComponent.SMTPDisconnect;}
- WorkingList := TList( PEMailMailBoxRecord(
- TheEMailMailBoxList.Items[ 1 ] )^.MBLTag );
- TheMBMessagesList := WorkingList;
- SetupEMailListBoxes;
- end;
-
- procedure TCCINetCCForm.MailServers1Click(Sender: TObject);
- begin
- SetupEmailServersInfoDisplay;
- CCICInfoDlg.ShowModal;
- end;
-
- procedure TCCINetCCForm.Mailboxes1Click(Sender: TObject);
- begin
- SetupEmailMailboxInfoDisplay;
- CCICInfoDlg.ShowModal;
- SetupEMailListBoxes;
- end;
-
- procedure TCCINetCCForm.Correspondents1Click(Sender: TObject);
- begin
- SetupEmailCorrespondentsInfoDisplay;
- CCICInfoDlg.ShowModal;
- end;
-
- procedure TCCINetCCForm.EMail3Click(Sender: TObject);
- begin
- CCICPrefsDlg.TabbedNoteBook1.PageIndex := 0;
- CCICPrefsDlg.Tag := 6;
- CCICPrefsDlg.ShowModal;
- end;
-
- procedure TCCINetCCForm.Paths1Click(Sender: TObject);
- begin
- CCICPrefsDlg.TabbedNoteBook1.PageIndex := 3;
- CCICPrefsDlg.Tag := 3;
- CCICPrefsDlg.ShowModal;
- end;
-
- procedure TCCINetCCForm.ExitEMailRequired1Click(Sender: TObject);
- begin
- if not ThePOP3SMTPComponent.Connection_Established then exit;
- DoPOP3SMTPDisconnect;
- SaveEMailMailBoxFile( WhichServer );
- SaveEMailCorrespondentsFile;
- DisablePOP3SMTPMenus;
- EMailLoaded := false;
- end;
-
- procedure TCCINetCCForm.TrashMarkedMessages1Click(Sender: TObject);
- begin
- ThePOP3SMTPComponent.TrashAllMarkedMessages( ListBox2 ,
- PEMailMailboxRecord( TheEMailMailBoxList.Items[ ListBox1.Itemindex ] ));
- TheMBMessagesList := TList( PEMailMailboxRecord(
- TheEMailMailBoxList.Items[ ListBox1.Itemindex ] )^.MBLTag );
- PopulateLB2WithMessageHeaders;
- end;
-
- procedure TCCINetCCForm.EmptyTrash1Click(Sender: TObject);
- var Counter_1 : Integer;
- begin
- for Counter_1 := 0 to TheEMailMailboxList.Count - 1 do
- begin
- ThePOP3SMTPComponent.PurgeTrashedMessageListings(
- PEMailMailBoxRecord( TheEMailMailboxList.Items[ Counter_1 ] ));
- end;
- TheMBMessagesList := TList( PEMailMailboxRecord(
- TheEMailMailBoxList.Items[ 0 ] )^.MBLTag );
- SetupEmailListboxes;
- end;
-
- procedure TCCINetCCForm.ComboBox2Change(Sender: TObject);
- var WhichCorrespondent : Integer;
- TheName : String;
- begin
- case Tag of
- 6 : begin
- if not NewMessageInProgress then exit;
- WhichCorrespondent := ComboBox2.ItemIndex;
- if WhichCorrespondent = -1 then exit;
- TheName := PConnectionsRecord(
- TheCorrespondentsList.Items[ WhichCorrespondent ] )^.CIPAddress;
- ThePOP3SMTPComponent.SetRecipient( Memo1 , TheName );
- end;
- end;
- end;
-
- procedure TCCINetCCForm.ComboBox3Change(Sender: TObject);
- var WhichCorrespondent : Integer;
- TheName : String;
- begin
- case Tag of
- 6 : begin
- if not NewMessageInProgress then exit;
- WhichCorrespondent := ComboBox3.ItemIndex;
- if WhichCorrespondent = -1 then exit;
- TheName := PConnectionsRecord(
- TheCorrespondentsList.Items[ WhichCorrespondent ] )^.CIPAddress;
- ThePOP3SMTPComponent.SetCarbonCopy( Memo1 , TheName );
- end;
- end;
- end;
-
- procedure TCCINetCCForm.MIMEDecode1Click(Sender: TObject);
- var Counter_1 : Integer;
- TheEMMRecord : PEmailMessageRecord;
- begin
- for Counter_1 := 0 to ListBox2.Items.Count - 1 do
- begin
- if ListBox2.Selected[ Counter_1 ] then
- begin
- TheEMMRecord :=
- PEMailMessageRecord( TheMBMessagesList.Items[ Counter_1 ] );
- TheMIMEObject.TheInputFileName := MailPath + '\' +
- TheEMMRecord^.MRFileName;
- TheMIMEObject.DecodeMIMEFile;
- end;
- end;
- end;
-
- procedure TCCINetCCForm.Cut1Click(Sender: TObject);
- begin
- Memo1.CutToClipboard;
- end;
-
- procedure TCCINetCCForm.Copy1Click(Sender: TObject);
- begin
- Memo1.CopyToClipboard;
- end;
-
- procedure TCCINetCCForm.CopytoFile1Click(Sender: TObject);
- var TempMemo : TMemo;
- begin
- TempMemo := TMemo.Create( self );
- TempMemo.parent := self;
- Tempmemo.Visible := false;
- TempMemo.Width := Memo1.Width;
- TempMemo.Height := Memo1.Height;
- Memo1.CopyToClipboard;
- TempMemo.PasteFromClipboard;
- SaveDialog1.Filename := '*.TXT';
- SaveDialog1.Title := 'Select File to Save To';
- if SaveDialog1.Execute then TempMemo.Lines.SaveToFile( SaveDialog1.Filename );
- TempMemo.Free;
- end;
-
- procedure TCCINetCCForm.Paste1Click(Sender: TObject);
- begin
- Memo1.PasteFromClipboard;
- end;
-
- procedure TCCINetCCForm.PastefromFile1Click(Sender: TObject);
- var TempMemo : TMemo;
- begin
- TempMemo := TMemo.Create( self );
- TempMemo.parent := self;
- Tempmemo.Visible := false;
- TempMemo.Width := Memo1.Width;
- TempMemo.Height := Memo1.Height;
- OpenDialog1.Filename := '*.*';
- OpenDialog1.Title := 'Select File to Paste From';
- if OpenDialog1.Execute then TempMemo.Lines.LoadFromFile( OpenDialog1.Filename );
- TempMemo.SelectAll;
- TempMemo.CopyToClipboard;
- Memo1.PasteFromClipboard;
- TempMemo.Free;
- end;
-
- procedure TCCINetCCForm.SpeedButton5Click(Sender: TObject);
- begin
- case Tag of
- 5 : AllMarkedArticles1Click( Self );
- 6 : TrashMarkedMessages1Click( self );
- end;
- end;
-
- procedure TCCINetCCForm.SpeedButton3Click(Sender: TObject);
- begin
- case Tag of
- 6 : MIMEDecode1Click( self );
- end;
- end;
-
- procedure TCCINetCCForm.SpeedButton1Click(Sender: TObject);
- begin
- case Tag of
- 5 : begin
- if ListBox2.Items.Count = 0 then exit;
- Listbox2.multiselect := false;
- If ListBox2.ItemIndex = -1 then ListBox2.ItemIndex := 0;
- ListBox2.ItemIndex := Listbox2.ItemIndex - 1;
- if ListBox2.Itemindex < 0 then
- Listbox2.Itemindex := ListBox2.Items.Count - 1;
- ListBox2DblClick( Self );
- ListBox2.Multiselect := true;
- ListBox2.SetFocus;
- end;
- 6 : begin
- if ListBox2.Items.Count = 0 then exit;
- Listbox2.multiselect := false;
- If ListBox2.ItemIndex = -1 then ListBox2.ItemIndex := 0;
- ListBox2.ItemIndex := Listbox2.ItemIndex - 1;
- if ListBox2.Itemindex < 0 then
- Listbox2.Itemindex := ListBox2.Items.Count - 1;
- ListBox2DblClick( Self );
- ListBox2.Multiselect := true;
- ListBox2.SetFocus;
- end;
- end;
- end;
-
- procedure TCCINetCCForm.SpeedButton2Click(Sender: TObject);
- begin
- case Tag of
- 5 : begin
- if ListBox2.Items.Count = 0 then exit;
- ListBox2.MultiSelect := false;
- If ListBox2.ItemIndex = -1 then ListBox2.ItemIndex := 0;
- ListBox2.ItemIndex := Listbox2.ItemIndex + 1;
- if ListBox2.Itemindex > ListBox2.Items.Count - 1 then
- Listbox2.Itemindex := 0;
- ListBox2DblClick( Self );
- ListBox2.MultiSelect := true;
- ListBox2.SetFocus;
- end;
- 6 : begin
- if ListBox2.Items.Count = 0 then exit;
- ListBox2.MultiSelect := false;
- If ListBox2.ItemIndex = -1 then ListBox2.ItemIndex := 0;
- ListBox2.ItemIndex := Listbox2.ItemIndex + 1;
- if ListBox2.Itemindex > ListBox2.Items.Count - 1 then
- Listbox2.Itemindex := 0;
- ListBox2DblClick( Self );
- ListBox2.MultiSelect := true;
- ListBox2.SetFocus;
- end;
- end;
- end;
-
- procedure TCCINetCCForm.ListBox2Click(Sender: TObject);
- var TheWorkingList : TList;
- TheNGARecord : PNewsGroupArticleRecord;
- TheNGRecord : PNewsGroupRecord;
- TheWorkingName : String;
- begin
- if ListBox2.Tag = 9 then
- begin
- TheNGRecord :=
- PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- TheWorkingList := TList( TheNGRecord^.GLTag );
- TheNGARecord := PNewsGroupArticleRecord(
- TheWorkingList.Items[ ListBox2.ItemIndex ] );
- TheWorkingName := NewsPath + '\' + TheNGARecord^.NGAArtFileName;
- TheUUDecodeList.Add( TheWorkingName );
- exit;
- end;
- case Tag of
- 5 : begin
- If ListBox2.Items.Count = 0 then exit;
- ComboBox1.Text := ListBox2.Items[ ListBox2.ItemIndex ];
- end;
- end;
- end;
-
- procedure TCCINetCCForm.AbortNewsgroupDownload1Click(Sender: TObject);
- begin
- GlobalAbortedFlag := true;
- end;
-
- procedure TCCINetCCForm.Marked1Click(Sender: TObject);
- var Counter_1,
- Counter_2 : Integer;
- TheNGRecord : PNewsGroupRecord;
- TheNGARecord : PNewsGroupArticleRecord;
- WorkingList : TList;
- begin
- for Counter_1 := 0 to ListBox1.Items.Count - 1 do
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] );
- if (( TheNGRecord^.GSubscribed ) and ( ListBox1.Selected[ Counter_1 ] )) then
- begin
- WorkingList := TList( TheNGRecord^.GLTag );
- for Counter_2 := 0 to ListBox2.Items.Count - 1 do
- begin
- TheNGARecord := PNewsGroupArticleRecord( WorkingList.Items[ Counter_2 ] );
- TheNGARecord^.NGARead := true;
- end;
- TheNNTPComponent.PurgeReadSentArticleListings( TheNGRecord );
- TheNGRecord^.GLowest := TheNGRecord^.GHighestAvailable;
- TheNGRecord^.GHighest := TheNGRecord.GLowest;
- TheNGRecord^.GTotalNew := 0;
- TheNGRecord^.GTotalArticles := 0;
- end;
- end;
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.All1Click(Sender: TObject);
- var Counter_1,
- Counter_2 : Integer;
- TheNGRecord : PNewsGroupRecord;
- TheNGARecord : PNewsGroupArticleRecord;
- WorkingList : TList;
- begin
- for Counter_1 := 0 to ListBox1.Items.Count - 1 do
- begin
- TheNGRecord := PNewsGroupRecord( TheNewsRCList.Items[ Counter_1 ] );
- if TheNGRecord^.GSubscribed then
- begin
- WorkingList := TList( TheNGRecord^.GLTag );
- for Counter_2 := 0 to ListBox2.Items.Count - 1 do
- begin
- TheNGARecord := PNewsGroupArticleRecord( WorkingList.Items[ Counter_2 ] );
- TheNGARecord^.NGARead := true;
- end;
- TheNGRecord^.GLowest := TheNGRecord^.GHighestAvailable;
- TheNGRecord^.GHighest := TheNGRecord.GLowest;
- TheNGRecord^.GTotalNew := 0;
- TheNGRecord^.GTotalArticles := 0;
- TheNNTPComponent.PurgeReadSentArticleListings( TheNGRecord );
- end;
- end;
- SetupNewsGroupListboxes;
- end;
-
- procedure TCCINetCCForm.File1Click(Sender: TObject);
- begin
- OpenDialog1.Filename := '*.uue';
- OpenDialog1.Filter := 'UUEncode Files|*.uue|All Files *.*';
- OpenDialog1.Title := 'Select File To Decode';
- if OpenDialog1.Execute then
- begin
- TheUUObject.SetInputFileName( OpenDialog1.FileName );
- TheUUObject.SetMultifileVector( CMV_SINGLE );
- TheUUObject.Decode;
- end;
- end;
-
- procedure TCCINetCCForm.SelectedArticle1Click(Sender: TObject);
- var TheWorkingList : TList;
- TheNGARecord : PNewsGroupArticleRecord;
- TheNGRecord : PNewsGroupRecord;
- TheWorkingName : String;
- begin
- TheNGRecord :=
- PNewsGroupRecord( TheNewsRCList.Items[ ListBox1.ItemIndex ] );
- TheWorkingList := TList( TheNGRecord^.GLTag );
- TheNGARecord := PNewsGroupArticleRecord(
- TheWorkingList.Items[ ListBox2.ItemIndex ] );
- TheWorkingName := NewsPath + '\' + TheNGARecord^.NGAArtFileName;
- TheUUObject.SetInputFileName( TheWorkingName );
- TheUUObject.SetMultifileVector( CMV_SINGLE );
- TheUUObject.Decode;
- end;
-
- procedure TCCINetCCForm.SelectMultipleArticles1Click(Sender: TObject);
- begin
- { Set tag so that listbox knows to keep track of hits}
- ListBox2.Tag := 9;
- ListBox2.MultiSelect := false;
- TheUUDecodeList := TStringList.Create;
- end;
-
- procedure TCCINetCCForm.DecodeSelections1Click(Sender: TObject);
- begin
- ListBox2.Tag := 5;
- ListBox2.MultiSelect := True;
- if TheUUDecodeList.Count = 0 then exit;
- TheUUObject.SetMultipleFilesList( TheUUDecodeList );
- TheUUObject.SetMultifileVector( CMV_MULTI );
- TheUUObject.Decode;
- TheUUDecodeList.Free;
- end;
-
- procedure TCCINetCCForm.SpeedButton4Click(Sender: TObject);
- begin
- case Tag of
- 5 : begin
- SelectedArticle1Click( Self );
- end;
- end;
- end;
-
- end.
-
-